[英]URL Scheme not working in iOS9
I am working on an app in which a user confirmation mail sent to user email. 我正在开发一个应用程序,其中用户确认邮件发送到用户电子邮件。 I am able to receive the mail in this format" http://www.sample.com//Register.aspx?xxx(with parameters)". 我能够以“ http://www.sample.com//Register.aspx?xxx(with parameters)”格式收到邮件。 Now on click of this mail i have to launch the register page in iOS9. 现在点击这封邮件我必须在iOS9中启动注册页面。
Note : if i type Register.aspx:// in safari app is opening but not from email URL. 注意 :如果我在safari应用程序中键入Register.aspx://正在打开但不是来自电子邮件URL。
I have done the following things in info.plist and in code 1.info.plist 我在info.plist和代码1.info.plist中完成了以下操作
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>Register.aspx</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>Register.aspx</string>
</array>
2.in app delegate i used: 2.in app delegate我用过:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
BOOL canBeOpened = [[UIApplication sharedApplication]
canOpenURL:[NSURL URLWithString:@"Register.aspx://"]];
if (canBeOpened) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message"
message:@"This is a url scheme"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message"
message:@"This is not a url scheme"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
You are registering the wrong part of the URL as the scheme. 您正在注册URL的错误部分作为方案。 The example you provide has a standard URL scheme of http
. 您提供的示例具有http
的标准URL方案。
The bit of the URL before the first colon is the scheme ( http
or https
typically). 第一个冒号之前的URL位是方案(通常为http
或https
)。 To use a custom scheme you need to make up a new scheme for the URL and output that URL in your email eg: 要使用自定义方案,您需要为URL构建新方案并在电子邮件中输出该URL,例如:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>mycoolapp</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mycoolapp</string>
</array>
Needs an email with a URL like: 需要一封包含以下网址的电子邮件:
mycoolapp://www.sample.com/Register.aspx
iOS 9 has made a small change to the handling of URL scheme. iOS 9对URL方案的处理做了一些小改动。 You must whitelist the url's that your app will call out to using the LSApplicationQueriesSchemes key in your Info.plist. 您必须使用Info.plist中的LSApplicationQueriesSchemes键将应用程序将调用的URL列入白名单。
Please check this link : http://awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes 请查看以下链接: http : //awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.