Classe NowPushSDK : Android
La classe NowPushSDK fournit la fonction nécessaire pour créer un NowPushService qui permet l’envoi de notifications non sollicitées (push) aux Android appareils.
NowPushSDK : makePushService(instanceURL : URL)
Crée un service NowPush.
| Nom | Type | Description |
|---|---|---|
| instanceURL | URL | URL de l’instance ServiceNow avec laquelle le NowPushService doit interagir. |
| Type | Description |
|---|---|
| Résultat <NowPushService> | NowPushService enveloppé dans un objet de résultat Kotlin. |
Cet exemple montre comment configurer la méthode makePushService() pour créer le service push.
private var nowPushService: NowPushService? = null
/**
* Create the NowPushService 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.
* NowPushService should be created after initializing the NowSDK.
*/
suspend fun getNowPushService(): NowPushService? {
if (nowPushService != null) return nowPushService
return NowPushSDK.makePushService(URL("https://instance-name.service-now.com")).getOrThrow()
.also { this.nowPushService = it }
}