【问题标题】:Using openTok after accept a Call (CallKit)接听电话后使用 openTok (CallKit)
【发布时间】:2017-07-25 08:37:24
【问题描述】:

我正在开发一个需要 opentok 和 callkit 来通知用户的项目。但是,当 openTok 尝试连接到会话时,应用程序会不断崩溃。 IDK现在发生了什么。这是我的工作流程和代码:

推送有关可用 opentok 会话的通知 -> 开始来电 -> 用户接受呼叫 -> 启动 opentok 故事板 -> 做一些后端工作 -> 连接到会话!!!!这就是它崩溃的时候。

错误: 线程 1:EXC_BAD_ACCESS(代码=2,地址=0x1968a0ad8)

此外,我想就接收通知征求意见。而不是在屏幕上显示通知。我想使用 callkit 开始通话,例如 whatsapp 或 fb messenger。也请给我一个提示。目前,我只能在发送推送通知时应用在前台时开始通话。

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    // If you are receiving a notification message while your app is in the background,
    // this callback will not be fired till the user taps on the notification launching the application.
    // TODO: Handle data of notification
    // With swizzling disabled you must let Messaging know about the message, for Analytics
    // Messaging.messaging().appDidReceiveMessage(userInfo)
    // Print message ID.
    if let messageID = userInfo[gcmMessageIDKey] {
        print("Message ID: \(messageID)")
    }

    // Print full message.
    print(userInfo)

    let aps = userInfo["aps"] as! [String: AnyObject]
    // 1
    if aps["content-available"] as? Int == 1 {

        let uuid = UUID(uuidString: MyVariables.uuid)
        AppDelegate.shared.displayIncomingCall(uuid: uuid!, handle: "Sanoste", hasVideo: false) { _ in
        }
    }else  {
        return
    }

    completionHandler(UIBackgroundFetchResult.newData)
}


func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {

    action.fulfill()
    AppDelegate.shared.openTok()
}


func openTok() {

    let mainStoryboard = UIStoryboard(name: "callView", bundle: nil)
    let vc = mainStoryboard.instantiateViewController(withIdentifier: "callViewController") as! callViewController

    vc.view.frame = UIScreen.main.bounds
    UIView.transition(with: self.window!, duration: 0.5, options: .transitionCrossDissolve, animations: {
        self.window!.rootViewController = vc
    }, completion: nil)

}

// Join a session from MBE
func joinSession() {

    var error: OTError?

    pSession = OTSession(apiKey: openTokSessionKey.pApiKey, sessionId: openTokSessionKey.pSessionId, delegate: self as OTSessionDelegate)
    pSession?.connect(withToken: openTokSessionKey.pToken, error: &error)
    if error != nil {
        print(error!)
    }

    sSession = OTSession(apiKey: openTokSessionKey.sApiKey, sessionId: openTokSessionKey.sSessionId, delegate: self as OTSessionDelegate)
    sSession?.connect(withToken: openTokSessionKey.sToken, error: &error)
    if error != nil {
        print(error!)
    }
}

有人帮忙吗?

【问题讨论】:

    标签: swift opentok callkit


    【解决方案1】:

    这次崩溃是一种警告。如果您在 Xcode 9 的项目设置中禁用“Main Thread Sanitizer”并重新构建项目,则可以解决此问题。

    【讨论】:

    • 您好,感谢您的回复。但是,它并没有解决问题。我用旧设备进行了测试。显然,问题出在 iOS11 beta 4 本身。它适用于 beta 3 或更低版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多