应用URL方案未注册

时间:2015-07-03 17:12:00

标签: ios redirect url-scheme

我已在Info.plist中创建了一个应用URL方案,以便我可以处理oauth重定向。

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>Lifestream</string>
        </array>
        <key>CFBundleURLName</key>
        <string>com.sullinger.lifestream.callback</string>
    </dict>
</array>

当我将应用程序部署到模拟器或设备时,然后关闭应用程序,打开Safari并输入Lifestream://com.sullinger.lifestream.callback,Safari告诉我它无法找到该网页。我是否错过了在操作系统中注册URL方案的步骤?

1 个答案:

答案 0 :(得分:0)

尝试使用:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>com.sullinger.lifestream.callback</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>callback</string>
            </array>
        </dict>
    </array>

在App代表中:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    NSLog(@"url recieved: %@", url);
    NSLog(@"query string: %@", [url query]);
    NSLog(@"host: %@", [url host]);
    NSLog(@"url path: %@", [url path]);
    return YES;
}