Classe NowPushSDK : Android

  • Rversion finale: Yokohama
  • Mis à jour 30 janv. 2025
  • 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 NowPush.

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