Reputation: 8328
I am trying to open my native iPhone application from a link in safari. I have followed this link to create a url schema. I have added appgo://
as my url schema and com.xxxx.appgo as Identifier under URL Types. Following is my link in web page in safari: Open iPhone App
But when I click on the link the app doesn't open up and safari produce an alert with error: Safari cannot enter the page as the address is invalid.
my bundle identifier: com.xxxxx.abc Note: My bundle identifier is different from the identifier in URL types. Can that be an issue?
Edit: I have made bundle identifier and url identifier same. I have also added following code in my app delegate:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
NSLog(@"application");
BOOL returnValue = NO;
NSString *urlString = [url absoluteString];
if([urlString hasPrefix:@"com.xxxx.appgo"]){
returnValue = YES;
}
return returnValue;
}
I am testing it in my iPad. I first install the latest version of app from xcode and then press on home button and then open the link in safari. But I am still getting the alert saying the Safari cannot enter the page as address is invalid. My link in safari:
<a href="appgo://">Open iPhone App</a>
Upvotes: 4
Views: 8230
Reputation: 1762
Yes. Your bundle identifier must be same as the URL types in the plis file.
For more you can refer to this link.
Upvotes: 0
Reputation: 12036
Implement in app delegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
BOOL returnValue = NO;
NSString *urlString = [url absoluteString];
if([urlString hasPrefix:@"appgo://"]){
returnValue = YES;
}
return returnValue;
}
Edit: Add in your info.plist file
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.xxxx.appgo</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appgo</string>
<string>yourSecondScheme</string>
</array>
</dict>
</array>
Upvotes: 5