[英]Custom URL Scheme
I want to open the app with myapp://something?id=123 when an user with the app installed visits http://myapp.com/something?id=123 and if an user does not have an app then open url in browser. 当安装了应用程序的用户访问http://myapp.com/something?id=123时 ,我想使用myapp:// something?id = 123打开应用程序;如果用户没有应用程序,则在浏览器。
Also, is Bundle URL Scheme can start with numeric? 另外, Bundle URL Scheme可以以数字开头吗?
My Current info.plist
file 我当前的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>
Edit: 编辑:
Following is the my scenario. 以下是我的情况。
I received an URL in email (eg http://techfuzionwithsam.wordpress.com ). 我在电子邮件中收到了一个URL(例如http://techfuzionwithsam.wordpress.com )。 When I tap on that URL on my iPhone i want to open my application if installed otherwise open the browser 当我在iPhone上点击该URL时,我想打开我的应用程序(如果已安装),否则打开浏览器
Your initial link in the email will need to send them to a page that can redirect them to the app or site. 电子邮件中的初始链接需要将它们发送到一个页面,该页面可以将其重定向到应用程序或网站。 Just include this javascript on the page: 只需在页面上包含此javascript:
setTimeout(function() {
if (!document.webkitHidden)
window.location = "http://www.myotherurl.com";
}, 250);
window.location = "myapp://something?id=123";
First you should include a statement on your page http://myapp.com/something like this: 首先,您应该在页面http://myapp.com/这样的页面上添加一个声明:
setTimeout(function() {
if (!document.webkitHidden)
window.location = "http://myapp.com/download";
}, 200);
window.location = "myapp://something?id=123";
In addition to ensure your app can execute right, you should add some statement in your app, like this: 除了确保您的应用程序可以正确执行之外,您还应该在应用程序中添加一些语句,如下所示:
- (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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.