我在項目中使用sinch SDK。第一次啓動時,不會收到類型爲voip的推送通知,但會在多次關閉/打開應用程序後收到。 這是客戶端首次推出時未收到推送通知
func initSinchClient(userIdentifier : String!) -> SINClient! {
if let _ = self.sinchClient{
self.sinchClient?.unregisterPushNotificationDeviceToken()
self.sinchClient?.stopListeningOnActiveConnection()
self.sinchClient?.terminate()
}
self.sinchClient = Sinch.client(withApplicationKey: SinchConstants.SinchAppKey, applicationSecret: SinchConstants.SinchApplicationSecret, environmentHost: SinchConstants.SinchEnvironmentHost, userId: userIdentifier)
self.sinchClient!.delegate = self
self.sinchClient!.call().delegate = self
self.sinchClient!.setSupportActiveConnectionInBackground(true)
self.sinchClient!.setSupportPushNotifications(true)
self.sinchClient!.setSupportCalling(true)
self.sinchClient?.enableManagedPushNotifications()
self.sinchClient!.start()
self.sinchClient!.startListeningOnActiveConnection()
if let pushTokenData = UserDefaults.standard.object(forKey: "PushNotificationToken"){
self.sinchClient!.registerPushNotificationData((pushTokenData as! NSData) as Data!)
}
return sinchClient
}
的初始化這是當我設置令牌
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) {
// Register VoIP push token (a property of PKPushCredentials) with server
if let sinchCLient = SinchManager.sharedInstance.sinchClient{
if let _ = SessionManager.sharedInstance.user {
sinchCLient.registerPushNotificationData(credentials.token)
}
}
}
我怎麼能如果你想推就不要開始aactive連接,主動解決此
我修改了代碼等你解決了這個問題推薦。這個問題沒有解決。在我終止應用程序並重新打開之前,不會收到推送通知。 –