尝试将 Sinch 合并到我的应用程序中,并且需要注销功能,因为我的应用程序将在同一设备上的不同用户之间共享。目前,同一设备还将接收对老用户的调用。
我正在查看这段代码
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.unregisterPushNotificationDeviceToken()
client.terminateGracefully()
}
self._client = nil
}
但不确定如何以及在哪里实现这个......在 Appdelegate 中?作为扩展?任何帮助将不胜感激!谢谢!
最佳答案
在 SINCH 中注销不起作用!即使您在 SINCH 中注销,该应用程序仍然可以接听电话!我找到了一个不是最好的解决方案,但它对我有用 在didReceiveIncomingPushWithPayload中,您需要从 header 获取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
关于swift - 注销 Sinch 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54336257/