gpt4 book ai didi

ios - 注销 devicetoken 后 Sinch 推送通知未打开

转载 作者:行者123 更新时间:2023-12-01 15:50:17 24 4
gpt4 key购买 nike

我在应用程序中有一项功能,用户可以通过该功能停止接收来自 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()
}

最佳答案

这对我有用,在调用取消注册方法后,您还需要关闭 sinch 客户端连接。

sinch_client?.unregisterPushNotificationDeviceToken()
sinch_client?.terminateGracefully()
sinch_client = nil

关于ios - 注销 devicetoken 后 Sinch 推送通知未打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46742255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com