【发布时间】:2012-01-02 12:12:59
【问题描述】:
我正在开发一个使用 PhoneGap 1.2.0 和 Snow Leopard、Xcode 4.2 并在 iPhone 模拟器中运行的 iPhone 应用程序。我通过 Oauth 连接到第 3 方网站,需要使用附加值重定向到我的应用程序。在 Jesse 的guide here 之后,我有以下代码:
// Objective-C code in your AppDelegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
// Do something with the url here
NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
[webView stringByEvaluatingJavaScriptFromString:jsString]; // freezes here
return YES;
}
// JS code loaded in your webview
function handleOpenURL(url)
{
// TODO: do something with the url passed in.
alert(url);
}
Objective C 代码位于“AppDelegate.m”中,JS 代码位于 index.html 中引用的单独 JS 文件中。该应用程序在“webView”行冻结。我相信当某些东西无法正确加载时,这个问题必须解决 - 有什么想法吗?当应用程序被冻结时,如果我单击 iPhone 按钮,然后单击应用程序图标,应用程序会重新加载,并且 'handleOpenUrl' JS 方法会根据警报运行。
【问题讨论】:
-
我目前遇到了同样的问题,想要一个解决方案。目前仅在模拟器中测试。
-
@MarcusJoe 希望我的回答对您有所帮助!
标签: javascript iphone oauth cordova