NowPushSDK クラス - Android

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:1分
  • NowPushSDK クラスは、要求されていない (プッシュ) 通知をAndroidデバイスに送信できるようにする NowPushService を作成するために必要な関数を提供します。

    NowPushSDK - makePushService(instanceURL: URL)

    NowPush サービスを作成します。

    表 : 1. パラメーター
    名前 タイプ 説明
    インスタンス URL URL NowPushService がやり取りする ServiceNow インスタンスの URL。
    表 : 2. 戻り値
    タイプ 説明
    結果<NowPushService> Kotlin Result オブジェクトにラップされた NowPushService オブジェクト。

    この例では、 makePushService() メソッドをセットアップしてプッシュサービスを作成する方法を示します。

    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 }
    }