简体   繁体   中英

iOS handleOpenURL isn't called when becoming active??? iOS 5.1 (this is not a 3.2 issue)

I use a URL scheme to open my app and parse the query string from the URL in -didFinishLaunchingWithOptions: . This works great, but it doesn't parse the new string when the app becomes active. I have implemented the -handleOpenURL: and openURL methods as follows, but neither seems to be called when the app becomes active...

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if (!url) 
        return NO;

    queryStrings = [self parseQueryString:[url query]];
    return YES;
}

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    if (!url) 
        return NO;
    queryStrings = [self parseQueryString:[url query]];
    return YES;
}

Please help! Thanks!

Use:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

The method you're using is deprecated.

handleOpenURL is deprecated on iOS 5: you should be using application:openURL:sourceApplication:annotation: instead - have you got an application:openURL method in your app as well? If not, add one and see if it gets picked up.

To clarify the above accepted answer. You probably want to use this (I was confused by the accepted answer as it only includes the function you need and not what you need to include inside the function):

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:[PFFacebookUtils session]];

}

- (void)applicationDidBecomeActive:(UIApplication *)application {

    [FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
}

I personally came to this issue through the Ray Wenderlich tutorial. There are also some good tutorials using Parse which show how to integrate the two.

The full tutorial this leads up to and from this point can be found here: https://parse.com/tutorials/integrating-facebook-in-ios

Hopefully this helps lessen confusion around this issue:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM