【发布时间】:2016-06-01 07:34:09
【问题描述】:
我正在开发一个应用程序,其中将用户确认邮件发送到用户电子邮件。 我可以接收这种格式的邮件“http://www.sample.com//Register.aspx?xxx(withparameters)”。 现在点击这封邮件,我必须在 iOS9 中启动注册页面。
注意:如果我在 safari 应用程序中键入 Register.aspx://,但不是来自电子邮件 URL。
我在 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.在我使用的应用代理中:
- (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];
}
}
【问题讨论】:
标签: ios objective-c url-scheme