2017-07-25 54 views
0

我正在開發一個需要opentok和callkit通知用戶的項目。但是,當openTok嘗試連接到會話時,應用程序會一直崩潰。 IDK現在正在發生什麼。這裏是我的工作流程和代碼:接受呼叫後使用openTok(CallKit)

關於可用opentok會話的推送通知 - >開始傳入呼叫 - >用戶接受呼叫 - >啓動opentok故事板 - >做一些後端的東西 - >連接到會話! !這是當它遭到破壞時。

錯誤: 線程1:EXC_BAD_ACCESS(代碼= 2,地址= 0x1968a0ad8) enter image description here

此外,我想請教關於收到通知。而不是在屏幕上顯示通知。我想開始使用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!) 
    } 
} 

有人幫忙嗎?

回答

1

這次崩潰是一種警告。如果您在Xcode 9的項目設置中禁用「Main Thread Sanitizer」並重建項目,可以解決問題。

+0

嗨,謝謝你的回覆。但是,它並沒有解決問題。我使用舊設備進行測試。顯然,問題是iOS11 beta 4本身。它適用於beta 3或更低版本。 –