NowWebSDK class - Android

  • Release version: Zurich
  • Updated July 31, 2025
  • 1 minute to read
  • The NowWebSDK class provides a single function that enables you to load web pages hosted on your ServiceNow instance in a native web view and Cabrillo. It automatically handles user authentication and session management instead of forcing users to log into the instance through a login web page.

    NowWebSDK - makeWebService(instanceURL: URL, nowWebSdkCallbacks: NowWebViewServiceDelegate? = null)

    Creates a NowWeb service.

    Table 1. Parameters
    Name Type Description
    instanceURL URL URL of the ServiceNow instance to access. For example, "https://instance.servicenow.com"
    nowWebSdkCallbacks NowWebViewServiceDelegate Callbacks for the host application to configure NowWebService.
    Table 2. Returns
    Type Description
    Result<NowWebService> NowWebService object wrapped in a Kotlin Result object.

    The following code example shows how to call this function.

     private var nowWebService: NowWebService? = null
    
    /**
      * Create the NowWebService once in the lifetime of the application, inside the Application
      * class or another manager class that will be injected into other classes via dagger/hilt.
      * NowWebService should be created after initializing the NowSDK.
      */
    suspend fun getNowWebService(): NowWebService? {
      if (nowWebService != null) return nowWebService
    
      return NowWebSDK.makeWebService(URL("https://instance-name.service-now.com"), object :
        NowWebViewServiceDelegate {
        override fun flowEnded(activity: Activity, flowName: String?) {
          Log.i("NowWebSdk", "flow ended")
        }
    
        override fun requestedDismissal(activity: Activity) {
          Log.i("NebWebSdk", "screen should be dismissed")
        }
    
        override fun navigationFailed(activity: Activity, error: String) {
          Log.i("NebWebSdk", "navigation failed")
        }
    
        override fun unsupportedUrl(activity: Activity, uri: Uri) {
          Log.i("NebWebSdk", "URL is unsupported")
        }
      }).getOrThrow()
          .also { this.nowWebService = it }
    }