Redirect to application if installed, otherwise to App Store

后端 未结 8 2552
渐次进展
渐次进展 2020-12-02 04:52

I know it\'s possible to link directly to an app in iOS by registering a custom scheme (e.g. so://) and it\'s also possible to link to the app in the appstore via itunes.

8条回答
  •  广开言路
    2020-12-02 05:17

    Yeah its pretty easy. This requires the app you want to open to have a url scheme declared in the plist:

    //if you can open your app
    if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"yourapp://"]])
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"yourapp://"]];
    }
    else
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ituneappstorelink"]];
    }
    

提交回复
热议问题