1、webView調(diào)用友盟中的QQ分享功能,崩潰錯(cuò)誤
*** Assertion failure in +[QQApi sendMessage:], /data/rdm/projects/18708/src/QQApi/QQApi.m:359
2017-05-09 17:27:29.997116+0800 WireShoper[10938:3459257]
2017-05-09 17:27:30.883339+0800 WireShoper[10938:3459603] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'TencentOpenApi must be called at main thread'
翻譯過來就是
由于異常終止應(yīng)用程序“NSInternalInconsistencyException”,原因是:“TencentOpenApi必須在主線程被調(diào)用的
解決方法:
if ([QQApiInterface isQQInstalled]) {//安裝了QQ
//創(chuàng)建分享消息對(duì)象
UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
//創(chuàng)建網(wǎng)頁內(nèi)容對(duì)象
UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:[appDefault objectForKey:@"shareTitle"] descr:[appDefault objectForKey:@"shareDescription"] thumImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[appDefault objectForKey:@"thumbUrl"]]]]];
//設(shè)置網(wǎng)頁地址
shareObject.webpageUrl = [appDefault objectForKey:@"webpageUrl"];
//分享消息對(duì)象設(shè)置分享內(nèi)容對(duì)象
messageObject.shareObject = shareObject;
dispatch_sync(dispatch_get_main_queue(), ^{
//Update UI in UI thread here
//調(diào)用分享接口
[[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_QQ messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
if (error) {
NSLog(@"************Share fail with error %@*********",error);
}else{
NSLog(@"response data is %@",data);
}
}];
});
}
分享到QQ空間也是一樣的處理方法
注意:在主線程調(diào)用友盟QQ分享是會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用友盟QQ分享
注意:在主線程調(diào)用友盟QQ分享是會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用友盟QQ分享
注意:在主線程調(diào)用友盟QQ分享是會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用友盟QQ分享
2、webView調(diào)用原生跳轉(zhuǎn)功能(跳轉(zhuǎn)的控制器主要做的是百度地圖定位功能,搖一搖)可能會(huì)出現(xiàn)崩潰,
崩潰錯(cuò)誤:

跳轉(zhuǎn)百度地圖定位.png
解決方法:
dispatch_sync(dispatch_get_main_queue(), ^{
RealTimeTrafficViewController * realTimeVC = [[RealTimeTrafficViewController alloc]init];
[self presentViewController:realTimeVC animated:YES completion:nil];
});
注意:在主線程調(diào)用可能會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用
注意:在主線程調(diào)用可能會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用
注意:在主線程調(diào)用可能會(huì)出現(xiàn)崩潰的,這個(gè)只限于webview調(diào)用