Open URL Schemes in IOS

后端 未结 5 2034
遇见更好的自我
遇见更好的自我 2020-12-18 08:59

I have 2 apps, which are meant for different purpose, where I should not allow user to use both apps in same device. How can I check whether other app installed or not? I t

5条回答
  •  难免孤独
    2020-12-18 09:27

    To know whether an app is installed or not

    -(BOOL) isAppInstalled:(NSString *)appUrl{
    
    return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:appUrl]]; // @ is not needed as you are passing input of function as a parameter.
    }
    

    To know whether any app got installed or not, invoke this function

    if( [self isAppInstalled:@"MyApp2://"]) {
    
         NSLog("The second app is installed");  //Perform your actions
     }
    

    Remember to include the second app's url scheme in First Apps LSApplicationURLScheme in its Info.plist.

提交回复
热议问题