My app is called Labmed, where a button will appear to open the "LAB Befund" App. If "LAB Befund" is already installed, open the app, instead of going to the AppStore.
Code:
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setValue:ltvController forKey:@"LAB Befund"];
[array addObject:dic];
NSString *LABAppURL = "LAB Befund://openApp?param1=XXX¶m2=YYY";
NSString *LABWebURL = @"https://itunes.apple.com/de/app/lab-befund/id1019115877?mt=8";
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:LABWebURL]];
NSLog(@"can open: %d", canOpenURL);
NSString *url = canOpenURL ? LABAppURL : LABWebURL;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
That's what I found in the internet so far. It is opening the Appstore EVERY time, of cause the app is installed.
I added the following statements to my .plist:
URL types
Item0
URL Schemes
Item0
URL Identifier
CanOpenURL return "NO".
CONCLUSION: Assuming two apps TestA and TestB. TestB wants to query if TestA is installed. “TestA” defines the following URL scheme in its info.plist file:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>testA</string>
</array>
</dict>
The second app “TestB” tries to find out if “TestA” is installed by calling:
[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"TestA://"]];
But this will normally return NO in iOS9 because “TestA” needs to be added to the LSApplicationQueriesSchemes entry in TestB’s info.plist file. This is done by adding the following code to TestB’s info.plist file:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>TestA</string>
</array>
And that's how it worked for me.
You must replace in LABAppURL
the "LAB Befund"
with the handler (URL Schema) you have put in Info.plist of LAB Befund.