在Safari浏览器中的Web应用程序中的链接打开一个iPhone应用程序

我试图从safari中的链接打开我的本地iPhone应用程序。 我已经按照这个链接来创build一个url模式。 我在URLtypes下添加了appgo://作为我的url模式和com.xxxx.appgo作为标识符。 以下是我在safari网页中的链接:打开iPhone应用程序但是,当我点击链接应用程序不打开,Safari浏览器产生一个错误提示:由于地址无效,Safari无法进入页面。

我的包标识符:com.xxxxx.abc注意:我的包标识符与URLtypes中的标识符不同。 这可能是一个问题吗?

编辑:我已经使捆绑标识符和URL标识符相同。 我还在我的应用程序委托中添加了以下代码:

 - (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; 

}

我正在iPad上testing它。 我首先从xcode安装最新版本的应用程序,然后按主页button,然后打开safari中的链接。 但是,我仍然得到警告说Safari不能进入页面,因为地址是无效的。 我在safari中的链接:

 <a href="appgo://">Open iPhone App</a> 

在应用程序委托中实现

  - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { BOOL returnValue = NO; NSString *urlString = [url absoluteString]; if([urlString hasPrefix:@"appgo://"]){ returnValue = YES; } return returnValue; } 

编辑:添加你的info.plist文件

 <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> 

是。 您的包标识符必须与plis文件中的URLtypes相同。

更多你可以参考这个链接 。

希望这会对你有所帮助。

祝一切顺利 !!!