0

我遇到了 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];
}

在这种情况下如何配置以使所有库正常工作?

4

1 回答 1

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如果至少有一个库返回,则此方法将返回YESNO否则返回。

于 2013-10-31T09:37:25.500 回答