Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

NowData framework- iOS

The NowData framework contains methods that enable the instantiation of NowData services, such as NowGraphQLService, NowTableService, NowAPIService (for custom APIs), andNowAttachmentService.

Parent Topic:Mobile SDK - iOS

NowData - makeApiService(instanceUrl: URL, path: String, completion: @escaping ((Result<NowApiService, NowServiceError>) -> Void))

Creates an instance of NowApiService, and once complete, calls the specified completion handler.

NameTypeDescription
instanceUrlURLURL of the ServiceNow instance whose REST APIs are to be accessed by the service.
pathStringAPI path. For example, if the API call is `https://xxx.service-now.com/api/now/sg/incident`, the path is `/api/now/sg/incident`.
completion@escaping \(\(Result​<NowApiService, Now​Service​Error>\) -> Void\)Completion handler that is called with a `Result` containing either an initialized `NowApiService` instance or a `NowServiceError` indicating why the initialization failed.
TypeDescription
None 

The following code example shows how to call this function.

let path = "api/now/sg"
let apiPublisher = apiService(for: path)

func apiService(for path: String) -> AnyPublisher<NowAPIService, ConfigurationError> {
  guard let instanceURL else {
    return Fail(error: ConfigurationError.invalidInstanceURL)
    .eraseToAnyPublisher()
  }
  return Future { promise in
    NowData.makeApiService(instanceUrl: instanceURL, path: path) { (result) in
      promise(result.mapError { .sdkError($0) })
    }
  }
  .eraseToAnyPublisher()
}

NowData - makeAttachmentService(instanceUrl: URL, completion: @escaping ((Result<NowAttachmentService, NowServiceError>) -> Void))

Creates an instance of NowAttachmentService, and after completion, calls the specified completion handler.

NameTypeDescription
instanceUrlURLURL of the ServiceNow instance whose attachments are to be accessed by the service.
completion@escaping ((Result​<NowAttachmentService, Now​Service​Error>) -> Void)Completion handler that is called with a Result<NowAttachmentService, NowServiceError> containing either an initialized NowAttachmentService instance or a NowServiceError indicating why the initialization failed.
TypeDescription
None 

The following code example shows how to call this function.

….
guard 
  let jwtUrl = URL(string: "http://13.57.38.237:8080"),
  let instanceUrl = URL(string: "https://mobilecoresdk.service-now.com") else {
    return
  }

// AuthorizationProvider – struct conforming to NowSDKAuthorizationProviding protocol
let authorizationProvider = AuthorizationProvider(userEmail: "sdk@servicenow.com", jwtProviderUrl: jwtUrl, clientId: "deb8756b452d201039231ca568f26511")

// PermissionProvider – class conforming to DevicePermissionDelegate protocol
let permissionProvider = PermissionProvider()
let config = NowSDKConfiguration(authorizationProvider: authorizationProvider, permissionDelegate: permissionProvider, logLevel: .debug)

do {
  try NowSDK.configure(with: config)
  initializeAttachmentService (with: instanceURL)
} catch {
  // Return ConfigurationError.sdkError(error)
}
…..

func initializeAttachmentService(instanceUrl: instanceURL) { result in
  switch result {
    case .success(let service)
      self?.attachmentService = service
    case .failure(let error)
      debug.print(“Creating Attachment service failed with error: \(error.localizedDescription)”)
      self?.attachmentService = nil
  }
}

NowData - makeGraphQLService(instanceUrl: URL, completion: @escaping ((Result<NowGraphQLService, NowServiceError>) -> Void))

Creates an instance of NowGraphQLService, and once complete, calls the specified completion handler.

NameTypeDescription
instanceUrlURLURL of the ServiceNow instance providing GraphQL services.
completion@escaping ((Result​<NowGraphQLService, Now​Service​Error>) -> Void)Completion handler that is called with a Result<NowGraphQLService, NowServiceError> containing either an initialized NowGraphQLService instance or a NowServiceError indicating why the initialization failed.
TypeDescription
None 
func initializeGraphQLService(instanceUrl: URL) {
  makeGraphQLService(instanceUrl: instanceUrl) { [weak self] result in
    switch result {
    case .success(let service):
      self?.graphQLService = service
    case .failure(let error):
      debugPrint("Creating GraphQL service failed with error: \(error.localizedDescription)")
      self?.graphQLService = nil
    }
  }
}

NowData - makeTableService(instanceUrl: URL, completion: @escaping ((Result<NowTableService, NowServiceError>) -> Void))

Creates an instance of NowTableService, and after it completes, calls the specified completion handler.

NameTypeDescription
instanceUrlURLURL of the ServiceNow instance whose tables are to be accessed by the service.
completion@escaping ((Result​<NowTableService, Now​Service​Error>) -> Void)Completion handler that is called with a Result<NowTableService, NowServiceError> containing either an initialized NowTableService instance or a NowServiceError indicating why the initialization failed.
TypeDescription
None 

The following code example shows how to call this function.

func initializeTableService(for instanceUrl: URL) {
  makeTableService(instanceUrl: instanceUrl) { [weak self] result in
    guard let self = self else { return }

    switch result {
      case .success(let tableService):
        self.tableService = tableService
        // Create a Paginator that will iterate over pages of customer support cases. The Paginator's response type will be
        // inferred from the Paginator's type definition (e.g. `Paginator<[CustomerServiceCase]>`).
        self.paginator = tableService.paginator(from: Self.tableName, configuration: self.fetchConfiguration)
        // Subscribe to the Paginator's publisher so we will be able to receive paged results.
        self.subscribeToPaginatorPublisher()
        // As we are now ready to start fetching data, inform the view controller.
        self.onReady(self)
      case .failure(let error):
        debugPrint("Creating table service failed with error: \(error.localizedDescription)")
        self.tableService = nil
        self.paginator = nil
    }
  }
}

sndocs is an independent community mirror and is not affiliated with or endorsed by ServiceNow.

ServiceNow, the ServiceNow logo, Now, and other ServiceNow marks are trademarks and/or registered trademarks of ServiceNow, Inc., in the United States and/or other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

© 2026 ServiceNow, Inc. All rights reserved.

Documentation content is redistributed under the Apache License 2.0 from the ServiceNowDocs repository.