簡體   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