自定义URL方案
问题描述:
我想与MYAPP打开应用程序://东西ID = 123时,与应用程序安装访问http://myapp.com/something?id=123和用户如果用户没有在浏览器的应用程序,然后打开URL?自定义URL方案
而且,是捆绑URL方案可以用数字开始?
我目前info.plist
文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
<key>CFBundleURLName</key>
<string>com.organizationname.myapp</string>
</dict>
</array>
....
</dict>
</plist>
编辑:
以下是我的方案。
我接收到的电子邮件中的URL(例如http://techfuzionwithsam.wordpress.com)。当我敲击在我的iPhone我想如果已安装,否则打开浏览器
答
在电子邮件您最初的链接需要将它们发送到可以将其重定向到应用程序或网站页面打开我的应用程序URL。只是包括在页面上此javascript:
setTimeout(function() {
if (!document.webkitHidden)
window.location = "http://www.myotherurl.com";
}, 250);
window.location = "myapp://something?id=123";
答
首先,你应该有你这样的http://myapp.com/something页上声明:
setTimeout(function() {
if (!document.webkitHidden)
window.location = "http://myapp.com/download";
}, 200);
window.location = "myapp://something?id=123";
除了确保您的应用程序可以执行的权利,你应该添加一些语句在你的应用中,像这样:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
...
NSString *outSideUrl = launchOptions[UIApplicationLaunchOptionsSourceApplicationKey];
if (outSideUrl) {
// ...
} else {
// ...
}
return YES;
}
什么?您的问题很不清楚,请提供更多信息。 – Popeye
先在网上搜索一下。计划不能以数字开头。你会在URL/URI规范中找到。 Javascript可以检测应用程序是否安装并根据结果重定向到不同的链接。 – Sulthan