---
sourceDocument: Brazil API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Initialize the NowSDK in your application

# Initialize the NowSDK in your application {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Initialize the NowSDK in your application

To utilize the NowSDK functionality in your iOS application, you must initialize the SDK once per application launch.
Initialization is asynchronous and should be started early, typically within theapplication(:didFinishLaunchingWithOptions:)method of the application delegate.
Reinitialization is not required when the app is foregrounded or when new scenes are detected.
Show full answer Show less  

## Initialization Process

Initialization requires two key components:

* **Authorization Provider:** An implementation of `NowSDKAuthorizationProviding` that supplies JWT tokens or guest authorization tokens.
* **Device Permission Delegate:** An implementation of `DevicePermissionDelegate` that handles device permission requests.

You configure the SDK by creating a `NowSDKConfiguration` object with these providers and an optional log level, then calling `NowSDK.configure(with:)`. Error handling should be included to manage any configuration exceptions.

## Guest User Access

The SDK supports guest users who are not authenticated. To enable guest access, the authorization provider should return an `AuthorizationToken` with the type set to `.guest`. The token string itself is not significant for guests.

## Logging Out

When a user logs out of your host application, you should invoke `NowSDK.logout()` to clear the user's sessions and tokens from the SDK, ensuring a clean state for subsequent users.

## Practical Benefits

* Enable secure and efficient integration of ServiceNow Mobile SDK features into your iOS app.
* Support both authenticated users via JWT tokens and guest users with simplified access.
* Manage device permissions flexibly through a delegate to align with your app's policies.
* Ensure proper session management by clearing user data on logout.  
To access the functionality provided by the NowSDK, you must first initialize the
NowSDK in your application.
The Mobile SDK initialization is asynchronous. It is a good practice to start the initialization process as early as possible, such as in the application delegate's
`application(application:didFinishLaunchingWithOptions:)` function. Initialization only needs to occur once per application launch. There is no need to reinitialize when foregrounded or when a new scene is
detected.

To initialize the ServiceNow
Mobile SDK in your iOS application you'll need an authorization provider conforming to `NowSDKAuthorizationProviding`, which uses your JWT provider information, and a delegate conforming to
`DevicePermissionDelegate`.

The following is an example of a structure of an SDK initialization. For additional code examples, refer to the ServiceNow
Mobile SDK sample application.

    // 

    //  JWTProvider.swift 

    import Foundation 
    import NowSDK 

    class JWTProvider: NowSDKAuthorizationProviding { 
      let token: String 

      init(token: String) { 
        self.token = token 
      } 

      func requestAuthorization(for instanceUrl: URL, completion: @escaping ([AuthorizationToken]?) -> Void) { 
        completion([AuthorizationToken(type: .jwt, token: token)]) 
      } 
    } 

    //
    //  PermissionProvider.swift 

    import Foundation
    import NowSDK 

    class PermissionProvider: DevicePermissionDelegate { 
      var isUserPermissionAllowed: Bool { Bool.random() } 

      func canRequestPermission(_ permission: DevicePermission) -> Bool { 
        guard isUserPermissionAllowed else { false } 
        return true 
      } 
    }

    //  
    //  AppDelegate.swift  

    import Foundation  
    import NowSDK  

    @main 
    class AppDelegate: UIResponder, UIApplicationDelegate { 
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 

        let jwtProvider = JWTProvider(token: "a_valid_token") 
        let permissionDelegate = PermissionProvider()  
        let logLevel: NowLogLevel = .debug 

        let config = NowSDKConfiguration(authorizationProvider: jwtProvider, permissionDelegate: permissionProvider, logLevel: logLevel)  

        do { 
          try NowSDK.configure(with: config) 
        } catch { 
          // Handle 'error' 
        }

        return true 

    }

## Guest users {#mobsdk-ios-init-nowsdk-in-app__section_cxw_xhx_kxb}

If the current user is not authenticated, it is possible to for them to access SDK functionality as a guest. To indicate that the current user is a guest, the requestAuthorization function in the authorization
provider should complete with a guest type of AuthorizationToken, as shown below. The token value in this case is not important so long as the AuthorizationTokenType is set to
`.guest`. For additional information on guest users, see [Configure guest user access](https://www.servicenow.com/docs/KHkz~pbUyzbWrEY2QDKSLA "To enable SDK services to be accessible by unauthenticated users, you must configure the Mobile SDK on your ServiceNow instance to allow guest user access. A guest user can view public web pages hosted in an instance using NowWeb, have a conversation as a guest using NowChat, access public data on the instance using NowTableService and NowGraphQLService, and access custom API services configured for unauthenticated users using NowAPIService.").

    //  GuestTokenProvider.swift 
    import Foundation 
    import NowSDK 
    class GuestTokenProvider: NowSDKAuthorizationProviding { 
        func requestAuthorization(for instanceUrl: URL,  
            completion: @escaping ([AuthorizationToken]?) -> Void) { 
            completion([AuthorizationToken(type: .guest, token: "")]) 
        } 
    } 

## Logging users out of the SDK

After a user is logged out of a host application, you should call the `NowSDK.logout()` method to clear that user's ServiceNow sessions and tokens from the SDK. For example:  

    func onLogout() {
      NowSDK.logout()
    } 


