我正在做一个需要opentok和callkit来通知用户的项目。但是,当openTok尝试连接到会话时,应用程序会不断崩溃。知道现在发生了什么。以下是我的工作流程和代码:
推送有关可用opentok会话的通知->开始传入呼叫->用户接受呼叫->启动opentok脚本->做一些后端工作->连接到会话!!!!这是它崩溃的时候。
错误:
线程1:EXC_BAD_ACCESS(代码=2,地址=0x1968a0ad8)
swift - 接受调用后使用openTok(CallKit)-LMLPHP
另外,我想征求有关接收通知的意见。而不是在屏幕上显示通知。我想用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!)
    }
}

有人帮忙吗?

最佳答案

这次坠机是一种警告。如果在Xcode 9的项目设置中禁用“主线程清理程序”并重新生成项目,则可以解决此问题。

关于swift - 接受调用后使用openTok(CallKit),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45298048/

10-11 08:10