试图将Sinch在我的应用程序和需要注销的功能,因为我的应用程序会在不同的用户在同一台设备上共享。目前,同样的设备也将获得老用户的调用。
我一直在寻找在此位的代码
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.unregisterPushNotificationDeviceToken()
client.terminateGracefully()
}
self._client = nil
}
但不知道如何和在哪里实施这个......中的appdelegate?作为扩展?任何帮助将不胜感激!谢谢!
注销在SINCH不行!该应用程序仍然收到呼叫,即使你是在SINCH注销!我找到了解决办法不是最好的,但它在我的工作在didReceiveIncomingPushWithPayload你需要从头部得到时,remote_id
func managedPush(_ managedPush: SINManagedPush!, didReceiveIncomingPushWithPayload payload: [AnyHashable : Any]!, forType pushType: String!) {
if pushType == "PKPushTypeVoIP" {
let result = SINPushHelper.queryPushNotificationPayload(payload)
if result?.isCall() != nil {
if let aHeaders = result?.call().headers {
callerIdz = aHeaders["to"] as? String
self.handleRemoteNotification(userInfo: payload as NSDictionary)
}
}
}
}//END
在handleRemoteNotification检查,如果localUser(谁在设备登录的用户)是一样的remote_Id的,如果它是你需要显示呼叫的通知,如果没有,你会忽略这个通知!
func handleRemoteNotification(userInfo: NSDictionary) {
if _client.userId != callerIdz {
print("Not match")
return
} else {
let result = self._client.relayRemotePushNotification(userInfo as! [AnyHashable : Any])
if result!.isCall() {
print("handle call notification")
}
if result!.isCall() && result!.call().isCallCanceled{
self.presentMissedCallNotificationWithRemoteUserId(userId: result!.call()!.callId)
}
}
}//END