Search code examples
iosiphoneappstore-approval

Open Appstore if i don't have installed the app


I have on my app a Shared button so i send a link www.example.com?id=publicationID when i open this link i can request to my server my publication with the ID and open the app with the correct information, but if i don´t have installed the app i can´t open it , but i need send to Appstore and download it.

Actually i Can only one thing open the app with the publication or open the AppStore.

I wanna open the Appstore and that the user can download my app, but first i need check if my app is already installed.

I can open the Appstore but i can't check if the installed app first


Solution

  • As other comments have stated this is not a brilliant question as there is no context.

    The only way to do this is using URL Schemes. This means you need to register a custom URL scheme in your info.plist for the application you want to open.

    This answer is probably one of the better ways of handling linking through a web page. But it appears that if the system does not understand the URL scheme an error will pop up. Add in that the required timeout will vary between devices. iPhone 6/6 Plus for example will only need < 1 second. iPhone 4 may need slightly longer.

    If you are trying to do this from an application you can use 2 methods in UIApplication.

    You can check to see if the app is installed by using the [[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"myapp://"]];

    If this returns true, then you can call [[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"myapp://"]];

    The OpenURL also returns a boolean value as to whether the url can be opened. But I believe it is good practise to check with the canOpenURL method first.