NowPushService class - Android

concept brazil Updated Sep 10, 2026 3 min read NowPushServiceAndroidAPI.md
Raw file servicenow.com

The NowPushService class provides functions that enable interaction with the Push Notification service.

Name

Description

configuration

Service configuration to associate with the service.Data type: NowServiceConfiguration

**Parent Topic:**[Mobile SDK - Android](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/cllent-mobile-api-reference/MobileSDKAndroidAPI.md)

NowPushService - handlePush(remoteMessage: RemoteMessage, successCallback: Consumer<NowPushPayload>, errorCallback: Consumer<Throwable>)

Processes a push notification request.

Note: Currently the only implemented push notification type is NowPushVirtualAgent. Any other passed push notification type returns a NotSupportedPushError object.

Name Type Description
remote Message Remote Message Notification as received by com.google.firebase.messaging.FirebaseMessagingService.onMessageReceived. For additional information, see Receive messages in an Android app.
success Callback Consumer <NowPushPayload> Callback to return the processed NowPushPayload to.
error Callback Consumer <Throwable> Callback to return the thrown error to. If the error NotSupportedPushError is thrown, the notification type is not supported by the mobile SDK, and must be processed outside of the mobile SDK framework.
Type Description
None

This example shows how to override onMessageReceived() and pass the RemoteMessage through to the NowPushService. If the NowPushService recognizes the notification type, it processes the request and returns the notification object for the application to handle. Otherwise it throws the NotSupportedPushError.

Text
override fun onMessageReceived(remodeeMessage: RemoteMessage){  pushService.handlePush(remoteMessage, { push ->    when (push) {      is NowPushVirtualAgent → handleVirtualAgentPush(push)    }, { error ->        Log.e(TAG, "Unknown push", error)        handleAppPushNotification(remoteMessage)    })}

NowPushService - registerPushToken(pushToken: String, pushApp: String, successCallback: Runnable, errorCallback: Consumer<Throwable>)

Registers a unique Firebase token with the ServiceNow instance used to identify the push notifications for the current Android device and specified application.

In order for the ServiceNow instance to generate notifications Android device to receive notifications from the application, this token must be registered.

Name Type Description
pushToken String Firebase token retrieved by either com.google.firebase.messaging.FirebaseMessaging.getToken or com.google.firebase.messaging.FirebaseMessagingService.onNewToken.
pushApp String Name of the push application as specified in the Push Application table on the associated ServiceNow instance.
success Callback Runnable Callback executed when the token registration is successful.
errorCallback Consumer <Throwable> Callback executed when the token registration fails.
Type Description
None

This example registers a push token for the current Android device and the application "PushAppName".

Java
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->  val token = task.result
  if (!task.isSuccessful || token == null) {    throw Exception("Unable to fetch token"))  }
  pushService.registerPushToken(token, "PushAppName", {    Log.v(TAG, "Successfully registered push token")  }, { e ->    Log.e(TAG, "Error registering push", e)  })}

NowPushService - unregisterPushToken(pushToken: String, pushApp: String, successCallback: Runnable, errorCallback: Consumer<Throwable>)

Unregisters the specified Firebase push token with the associated ServiceNow instance.

Name Type Description
pushToken String Firebase token to unregister. Retrieved by either com.google.firebase.messaging.FirebaseMessaging.getToken or com.google.firebase.messaging.FirebaseMessagingService.onNewToken.
pushApp String Name of the push application associated with the token to unregister. This information is stored in the Push Application table on the associated ServiceNow instance.
success Callback Runnable Callback executed when the token unregistration is successful.
erro rCallback Consumer <Throwable> Callback executed when the token unregistration fails.
Type Description
None

This code example shows how to unregister a push token such as when the user logs out of the application.

Text
pushService.unregisterPushtoken(token, "PushAppName", {  Log.v(TAG, "Successfully unregistered push token")},  { e ->  Log.e(TAG, "Error unregistering push", e)})
Search documentation
Search document titles and file paths on the brazil branch