Classe NowPushSDK - Android

  • Versão de lançamento: Washingtondc
  • Atualizado 1 de fev. de 2024
  • 1 min. de leitura
  • A classe NowPushSDK fornece a função necessária para criar um NowPushService que permite o envio de notificações não solicitadas (por push) para dispositivos Android.

    NowPushSDK - makePushService(instanceURL: URL)

    Cria um serviço NowPush.

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    URL da instância URL URL da instância ServiceNow com a qual o NowPushService deve interagir.
    Tabela 2. Retorna
    Tipo Descrição
    Resultado<NowPushService> Objeto NowPushService encapsulado em um objeto Resultado do Kotlin.

    Este exemplo mostra como configurar o método makePushService() para criar o serviço de envio por 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 }
    }