---
sourceDocument: Référence API Brésil
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/fr-FR/api-reference

 Release :

    - brazil

ft:locale :

    - fr-FR

ft:publication_title :

    - Référence API Brésil

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Classe NowWebService : iOS

# Classe NowWebService : iOS {#ariaid-title1}

Rversion finale: Brazil  
Mis à jour 10 sept. 2026  
![](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 | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/9cObKA8G_LYnlkCSPBz3eg#NowServiceConfigurationiOSStruct "La structure NowServiceConfiguration définit les informations de configuration d’un service de fonctionnalité.") | 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 | [NowServiceConfiguration](https://servicenow-prod.fluidtopics.net/9cObKA8G_LYnlkCSPBz3eg#NowServiceConfigurationiOSStruct "La structure NowServiceConfiguration définit les informations de configuration d’un service de fonctionnalité.") | Paramètres de configuration à utiliser lors de l'initialisation de l'instance NowWebService. |
| coreServiceProvider | NowCoreServiceProviding | Facultatif. Fournisseur de service à associer à l'instance NowWebService. Par défaut : néant |
[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 | [Protocole NowWebThemeable : iOS](https://servicenow-prod.fluidtopics.net/N6UqQfS1wogFs2h_19dQvw "Le protocole NowWebThemeable fournit des propriétés qui vous permettent de remplacer les couleurs utilisées dans les pages Web hébergées sur votre ServiceNow instance dans une vue Web native.") | Facultatif. NowUIThemeable Protocole à 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 | PreloadWebCacheCompletion | 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 |
|-|-|
| Aucune |   |
[Tableau 6. Renvoie]

{#NWebServ-preloadWebCache_A_S__table_kfm_zbs_gyb}  
L'exemple suivant montre comment utiliser la fonction webService.preloadWebCache() pour précharger des 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)
      }
    }


