How to handle UIApplication handleOpenURL with multiple URL's

前端 未结 1 1251
傲寒
傲寒 2020-12-24 02:16

I have an app that will be using both Facebook and Instagram API\'s, both of which require me to use this delegate method:

- (BOOL)application:(UIApplication         


        
相关标签:
1条回答
  • 2020-12-24 02:54

    Facebook and Instagram both had you setup a custom URL scheme for their services, so we will use that to filter the URL.

    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    
        if ([[url scheme] isEqualToString:INSTAGRAM_SCHEME])
            return [self.instagram handleOpenURL:url];
    
        if ([[url scheme] isEqualToString:FACEBOOK_SCHEME])
            return [PFFacebookUtils handleOpenURL:url];
    
        return NO;
    
    }
    

    Where you define your variables as

    #define INSTAGRAM_SCHEME @"ig12345678910"
    #define FACEBOOK_SCHEME  @"fb12345678910"
    

    exactly as you did in your Info.plist file

    0 讨论(0)
提交回复
热议问题