正在尝试在我的应用程序中整合Sinch,需要一个注销功能,因为我的应用程序将在同一设备上的不同用户之间共享。目前,同一设备还将接收向旧用户发出的呼叫。
我在看这段代码
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.unregisterPushNotificationDeviceToken()
client.terminateGracefully()
}
self._client = nil
}但不确定如何以及在哪里实现此功能...在Appdelegate中?作为一个扩展?任何帮助都将不胜感激!谢谢!
发布于 2019-02-07 20:23:22
在小的地方注销不起作用!即使您在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)
}
}
}//ENDhttps://stackoverflow.com/questions/54336257
复制相似问题