I am doing one iOS application. In that, I have one module for UITableView. In that UITableView, I am displaying some list of apps names. Those names are coming from my server. Those are my company applications. So, i don't know how many apps would come from server. Once user clicks on the UITableViewCell, I need to check whether that apps already installed or not on that device. If not installed, user needs to goes to appstore using app store link of that app. I have checked some tutorials. In that they said, using url schemes we can do this scenario. But, i don't have url schemes for those urls, because those apps are coming from server. Also, I tried with following methods
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/nameOfMyApp"]];
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"nameOfMyAppOrurl:"]];
but nothing helped me. Can anyone idea about this issue, if so please give your valuable suggestions.
You will need to have a App URL scheme for each app in the list, there is no other way to check whether the app is installed.
I'm guess the list form you server will be in JSON, something like:
{
"name" : "My Cool APP",
"scheme" :"mycoolapp:",
"itunes": "http:///...../"
}
Then just do something like:
if ([[UIApplication sharedApplication] canOpenURL:scheme]) {
[[UIApplication sharedApplication]openURL:scheme];
}
else {
[[UIApplication sharedApplication]openURL:itunesURL];
}
Custom url schemes is the preferred way to solve this issue. You have to know all url schemes (that means that all the apps should have one configured) for each app you need to check availability for. For your specific case, you'll need a backend support, i.e. server should provide a scheme for each app (server should be informed about the schemes as well).
Another option is using shared data in keychain, there's an answer here about sharing data between apps via keychain. You should think up a solution for that, but as long as you can share data between known group of apps, you can implement something on top of that technique. Note that second solution requires you to own all the apps (or be able to affect their configuration).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With