---
sourceDocument: Référence de l’API Xanadu
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/fr-FR/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - fr-FR

ft:publication_title :

    - Référence de l’API Xanadu

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Classe NowWebService : iOS

# Classe NowWebService : iOS {#ariaid-title1}

* Rversion finale: Xanadu
* 
* Mis à jour 1 août 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes de lecture

La classe NowWebService fournit des fonctions qui permettent de parcourir des pages Web sur une ServiceNow instance.
{#NowWebServiceiOSAPI__table_vx2_klw_5pb__entry__3}

| Nom | Type | Description |
|-|-|-|
| configuration | [Configuration Now ServiceConfiguration](https://servicenow-prod.fluidtopics.net/V01HrOtfNsIM7_JMqFBMSg#NowServiceConfigurationiOSStruct "La structure NowServiceConfiguration définit les informations de configuration d’un service d’fonctionnalités.") | Paramètres de configuration à utiliser lors de l'initialisation de l'instance NowWebService. |
[Tableau 1. Propriétés]

{#NowWebServiceiOSAPI__table_vx2_klw_5pb}

## NowWebService : init(configuration : NowServiceConfiguration, coreServiceProvider : NowCoreServiceProviding ? = nil) {#ariaid-title2}

Initialise une instance NowWebService.
{#NWebServ-init_O_S__table_lc2_n13_ppb__entry__3}

| Nom | Type | Description |
|-|-|-|
| configuration | [Configuration Now ServiceConfiguration](https://servicenow-prod.fluidtopics.net/V01HrOtfNsIM7_JMqFBMSg#NowServiceConfigurationiOSStruct "La structure NowServiceConfiguration définit les informations de configuration d’un service d’fonctionnalités.") | Paramètres de configuration à utiliser lors de l'initialisation de l'instance NowWebService. |
| coreServiceProvider (en anglais seulement) | NowCoreServiceProviding | Facultatif. Fournisseur de service à associer à l'instance NowWebService. Par défaut : nul |
[Tableau 2. Paramètres]

{#NWebServ-init_O_S__table_lc2_n13_ppb}  
L'exemple de code suivant montre comment appeler cette méthode.

    guard let coreService = NowSDK.core() else {
      // Error with NowServiceError.sdkNotConfigured
      return
    }
    guard 
      let instanceUrl = URL(string: "http://sample.service-now.com") , 
      let serviceConfig = NowSDK.makeServiceConfiguration(for: instanceUrl) else {
        // Could not create service -- 
        // NowServiceError.serviceConfigurationInvalid
        return
    }

    let webService = NowWebService(configuration: serviceConfig, coreServiceProvider: coreService)

## NowWebService : makeWebViewController (pour l'URL : URL, délégué : NowWebViewControllerDelegate, thème : NowWebThemeable) {#ariaid-title3}

Crée un objet UIViewController qui héberge la vue Web.
{#NWebServ-makeWebViewCont_S_S_O__table_pnt_hb3_ppb__entry__3}

| Nom | Type | Description |
|-|-|-|
| Pour l'URL | URL | URL de la page Web à charger. Cette page Web doit se trouver sur l'instance cible ServiceNow avec laquelle le service a été initialisé. |
| délégué | NowWebViewControllerDelegate | Facultatif. Objet qui reçoit les événements de rappel du WebViewController vers l'application native. |
| thème | NowWebThemeable | Facultatif. NowUIThemeable protocol à appliquer aux éléments d'interface utilisateur du contrôleur de vue, tels que la couleur. Par défaut : NowWebDefaultTheme(nowUITheme : NowUIDefaultTheme()) |
[Tableau 3. Paramètres]

{#NWebServ-makeWebViewCont_S_S_O__table_pnt_hb3_ppb} {#NWebServ-makeWebViewCont_S_S_O__table_qnt_hb3_ppb__entry__2}

| Type | Description |
|-|-|
| Résultat \<NowWebViewController, NowWebServiceError\> | Réussite : objet NowWebViewController Échec : objet NowWebServiceError |
[Tableau 4. Renvoie]

{#NWebServ-makeWebViewCont_S_S_O__table_qnt_hb3_ppb}  
<br />

    private func webViewController(for url: URL) -> NowWebViewController? {
      guard let webService = webService else {
        debugPrint("Web service not initialized")
        return nil
      }
            
      let result = webService.makeWebViewController(for: url, delegate: self, theme: CarrascoWebTheme(nowUITheme: CarrascoTheme()))
      switch result {
        case .success(let viewController):
          return viewController
        case .failure(let error):
          debugPrint("Web view creation failed with error: \(error.localizedDescription)")
      }
      return nil
    }

## NowWebService - preloadWebCache(urls : \[URL\], complétion : PreloadWebCacheCompletion ? = nil) lève {#ariaid-title4}

Précharge une liste de pages spécifiées avec des ressources pouvant être mises en cache en arrière-plan (par NowWeb) pour améliorer les temps de chargement initiaux.
{#NWebServ-preloadWebCache_A_S__table_jfm_zbs_gyb__entry__3}

| Nom | Type | Description |
|-|-|-|
| URL | Tableau d'objets d'URL | URL des pages à précharger. |
| achèvement | PréchargementWebCacheCompletion | Facultatif. Fermeture pour informer l'appelant que le chargement des pages Web est terminé. |
[Tableau 5. Paramètres]

{#NWebServ-preloadWebCache_A_S__table_jfm_zbs_gyb} {#NWebServ-preloadWebCache_A_S__table_kfm_zbs_gyb__entry__2}

| Type | Description |
|-|-|
| Aucun |   |
[Tableau 6. Renvoie]

{#NWebServ-preloadWebCache_A_S__table_kfm_zbs_gyb}  
L'exemple suivant montre comment utiliser la fonction webService.preloadWebCache() pour précharger les pages spécifiées.

    private func preloadURLs(urls: [URL]) {
      guard let webService = webService else {
        debugPrint("Web service not initialized")
        return
      }
      do {
           try webService.preloadWebCache(urls: urls) {
             debugPrint("URLs did complete preloading")
           }
                
      } catch {
          debugPrint(error.localizedDescription)
      }
    }


