Initialize the NowSDK in your application
-
- UpdatedFeb 1, 2024
- 2 minutes to read
- Washington DC
- Developer guides
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.
The following diagram shows the initialization sequence for NowSDK and feature services:

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.
Guest users
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.
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: