我在AppDelegate中遇到问题
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
许多库必须在此函数中为其配置添加一些返回代码。像这样:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
//facebook
//attempt to extract a token from the url
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall *call) {
NSLog(@"In fallback handler");
}];
//library
BOOL urlHasBeenHandledByDispatcher = [[GRKConnectorsDispatcher sharedInstance] dispatchURLToConnectingServiceConnector:url];
if ( urlHasBeenHandledByDispatcher ) return YES;
return NO;
//facebookSession
return [FBSession.activeSession handleOpenURL:url];
}
如何在这种情况下配置以使所有库工作?
答案 0 :(得分:2)
您应该只更改一次代码并返回值。请尝试以下代码:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
//facebook
//attempt to extract a token from the url
BOOL result = NO;
result |= [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
fallbackHandler:^(FBAppCall *call) {
NSLog(@"In fallback handler");
}];
//library
result |= [[GRKConnectorsDispatcher sharedInstance] dispatchURLToConnectingServiceConnector:url];
//facebookSession
result |= [FBSession.activeSession handleOpenURL:url];
return result;
}
如果至少有一个库返回YES
,则此方法将返回YES
,否则返回NO
。