繁体   English   中英

URL方案在iOS9中不起作用

[英]URL Scheme not working in iOS9

我正在开发一个应用程序,其中用户确认邮件发送到用户电子邮件。 我能够以“ http://www.sample.com//Register.aspx?xxx(with parameters)”格式收到邮件。 现在点击这封邮件我必须在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.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];

    }
}

您正在注册URL的错误部分作为方案。 您提供的示例具有http的标准URL方案。

第一个冒号之前的URL位是方案(通常为httphttps )。 要使用自定义方案,您需要为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>

需要一封包含以下网址的电子邮件:

mycoolapp://www.sample.com/Register.aspx

iOS 9对URL方案的处理做了一些小改动。 您必须使用Info.plist中的LSApplicationQueriesSchemes键将应用程序将调用的URL列入白名单。

请查看以下链接: http//awkwardhare.com/post/121196006730/quick-take-on-ios-9-url-scheme-changes

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM