VNG-Zalo / ZaloSDK-iOS

MIT License
7 stars 5 forks source link

-[ZMBProgressHUD initWithView:] + 213 View must not be nil. #4

Closed freezy7 closed 4 years ago

freezy7 commented 4 years ago

SDK Version: 2.4.0912

occur system version: iOS 9.0.2, 9.3.2, 9.3.5 and iOS 10.0.1, 10.3.2, 10.3.4

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x18e54c1c0 __exceptionPreprocess
1  libobjc.A.dylib                0x18cf8455c objc_exception_throw
2  CoreFoundation                 0x18e54c094 +[NSException raise:format:]
3  Foundation                     0x18efd682c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  xxxxxxxxxx                      0x100c7921c -[ZMBProgressHUD initWithView:] + 213 (ZMBProgressHUD.m:213)
5  xxxxxxxxxx                      0x100c782b4 +[ZMBProgressHUD showHUDAddedTo:animated:] + 117 (ZMBProgressHUD.m:117)
6  xxxxxxxxxx                      0x100c817e8 +[ZDKProgressHUD showLoadingInController:text:] + 59 (ZDKProgressHUD.m:59)
7  xxxxxxxxxx                      0x100c816f0 +[ZDKProgressHUD showLoadingInController:] + 53 (ZDKProgressHUD.m:53)
8  xxxxxxxxxx                      0x100c4a4e4 -[ZOZaloAuthenticator(Google) exchangeAuthorizationCode:] + 146 (ZOZaloAuthenticator+Google.m:146)
9  xxxxxxxxxx                      0x100c4a0c0 -[ZOZaloAuthenticator(Google) didLoginGgWithCallbackUrl:] + 125 (ZOZaloAuthenticator+Google.m:125)
10 xxxxxxxxxx                      0x100c49ccc -[ZOZaloAuthenticator(Google) ggHandleOpenURL:sourceApplication:] + 95 (ZOZaloAuthenticator+Google.m:95)
11 xxxxxxxxxx                      0x100c30838 -[ZOZaloAuthenticator handleOpenURL:sourceApplication:] + 447 (ZOZaloAuthenticator.m:447)
12 xxxxxxxxxx                      0x100c2c624 -[ZaloSDK application:openURL:sourceApplication:annotation:] + 414 (ZDK.m:414)
13 xxxxxxxxxx                      0x100c6e1e8 -[ZDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 72 (ZDKApplicationDelegate.m:72)
14 xxxxxxxxxx                      0x10031629c -[AppDelegate application:openURL:options:] + 278 (AppDelegate.m:278)
15 UIKit                          0x1946248ac __45-[UIApplication _applicationOpenURL:payload:]_block_invoke
16 UIKit                          0x194624338 -[UIApplication _applicationOpenURL:payload:]
17 SafariServices                 0x19c7d56d4 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:]
18 SafariServices                 0x19c7cd5f4 -[SFBrowserRemoteViewController willOpenURLInHostApplication:]
19 CoreFoundation                 0x18e552160 __invoking___
20 CoreFoundation                 0x18e445c3c -[NSInvocation invoke]
21 FrontBoardServices             0x1900ed904 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
22 FrontBoardServices             0x1900ed770 -[FBSSerialQueue _performNext]
23 FrontBoardServices             0x1900edb18 -[FBSSerialQueue _performNextFromRunLoopSource]
24 CoreFoundation                 0x18e4fa278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
25 CoreFoundation                 0x18e4f9bc0 __CFRunLoopDoSources0
26 CoreFoundation                 0x18e4f77c0 __CFRunLoopRun
27 CoreFoundation                 0x18e426048 CFRunLoopRunSpecific
28 GraphicsServices               0x18fea9198 GSEventRunModal
29 UIKit                          0x1943ff818 -[UIApplication _run]
30 UIKit                          0x1943fa550 UIApplicationMain
31 xxxxxxxxxx                      0x100247e68 main + 14 (main.m:14)
32 ???                            0x18d4085b8 (缺少)

Hello, we have meet this crash, this is only happen in the iOS 9 and iOS 10, please check is it has fixed in the new release version? Thanks.

liemvu commented 4 years ago

ZaloSDK has a hidden feature to login with google account, therefore it can handle google oauth callback from google. In your case, you should not call -[ZDKApplicationDelegate application:openURL:sourceApplication:annotation:] for google oauth callback.

freezy7 commented 4 years ago

@liemvu we also have google oath, this is the example code of my issue,

BOOL ggHandled = [[GIDSignIn sharedInstance] handleURL:url];
BOOL zaloHanled = [[ZDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];

did you mean I should change the code like this?

BOOL ggHandled = [[GIDSignIn sharedInstance] handleURL:url];
BOOL zaloHanled = NO;
if (!ggHandled) {
    zaloHanled = [[ZDKApplicationDelegate sharedInstance] application:app openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}
freezy7 commented 4 years ago

@liemvu Thank you very much, I have reproduced this problem and solved it according to the above method.