swift - 注销 Sinch 用户

标签 swift sinch

尝试将 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/

相关文章:

uitableview - 如何使用界面生成器在 swift 中创建几个 uitableview?

ios - 获取用户当前位置/获取经纬度值 watchkit/ios swift

swift - 单击 CallKit 中的应用程序图标时打开应用程序

ios - CallKit "call failed screen"出现

ios - Sinch 调用 header 在推送有效负载中收到,但在调用对象中为零

ios - 单独的类来存储输入

swift - 在 Swift 5.5 中编写同步和异步函数

ios - CloudKit - 哪些 CKError 应该作为 .partialFailure 处理,它们是否也应该作为非部分故障处理?

swift - Sinch Sms Verification 2.0.3 SDK Swift 3

android - 在android Lollipop 上启动应用程序时强制关闭