Classe NowPushSDK : Android

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 1 minute de lecture
  • 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 Now Push.

    Tableau 1. Paramètres
    Nom Type Description
    URL d’instance URL URL de l’instance ServiceNow avec laquelle NowPushService doit interagir.
    Tableau 2. Renvoie
    Type Description
    Résultat <NowPushService> Objet 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 }
    }