倩女幽魂推送通知在取消注册devicetoken后无法开启。

问题描述 投票:3回答:1

我的应用程序有一个功能,用户可以通过这个功能停止接收来自sinch的通知。但是在关闭通知后,当我试着让它打开时,用户仍然没有收到聊天信息的通知。

我使用了以下功能来让用户接收来自sinch的通知。

let sinchUserID:String = userID as String

    self.sinchClient = Sinch.client(withApplicationKey: SINCH_APPLICATION_KEY, applicationSecret: SINCH_APPLICATION_SECRET, environmentHost: "sandbox.sinch.com", userId: sinchUserID)

    self.sinchClient!.setSupportMessaging(true)

    self.sinchClient!.enableManagedPushNotifications()
    // or
    self.sinchClient!.setSupportActiveConnectionInBackground(true)


    self.sinchClient!.delegate = self

    self.sinchClient!.start()

    self.sinchClient!.startListeningOnActiveConnection()

    self.sinchClient?.setPushNotificationDisplayName(ALERT_TITLE)


    self.push = Sinch.managedPush(with: SINAPSEnvironment.development)
    self.push?.delegate = self
    self.push?.setDesiredPushTypeAutomatically()


    self.push?.setDisplayName(UserDefaults.standard.value(forKey: "userFirstname") as! String)

    self.push?.setDesiredPushType(SINPushTypeRemote)
    self.push?.registerUserNotificationSettings()

    if UserDefaults.standard.integer(forKey: "newMessageStatus") == 0
    {
        self.sinchClient?.registerPushNotificationDeviceToken(UserDefaults.standard.value(forKey: "deviceTokenForSinch") as! Data, type: SINPushTypeRemote, apsEnvironment: SINAPSEnvironment.development)
    }
    else
    {

        self.sinchClient?.unregisterPushNotificationDeviceToken()
    }
ios swift sinch
1个回答
0
投票

这对我来说是有效的,在调用unregister方法后,你也需要关闭sinch客户端连接。

sinch_client?.unregisterPushNotificationDeviceToken()
sinch_client?.terminateGracefully()
sinch_client = nil
© www.soinside.com 2019 - 2024. All rights reserved.