【发布时间】:2013-05-02 18:15:26
【问题描述】:
MeteorJS:https://github.com/zeroasterisk/Presenteract
PhoneGap:https://github.com/zeroasterisk/Presenteract-PhoneGap-ios
- 我在 iOS 上的 PhoneGap 2.7 中运行 MeteorJS 应用程序。
- MeteorJS 应用程序通过外部 URL 加载,在
config.xml中设置为<content src="http://presenteract.meteor.com" /> - 我在浏览器中使用 oAuth 没有问题
-
access配置使用完整的通配符<access origin="*" /> - 该应用程序运行良好,与它的浏览器版本相同....
但是当我在 PhoneGap 中尝试 oAuth 时,我会遇到以下错误:
Failed to load webpage with error: The operation couldn’t be completed.
(NSURLErrorDomain error -999.)
(注意:来自 Google、Facebook 和 Twitter 的 oAuth 尝试都是相同的。加载外部站点,登录正常进行,并在重定向回我的应用程序的主 URL 时)
我查看了其他 StackOverflow 报告并进行了一些谷歌搜索...我发现的最有用的是:
Facebook dialog failed with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.) & 相关:NSURLErrorDomain error -999 - links failing in iOS
这看起来很有希望,但我不知道如何将这个解决方案翻译成PhoneGap...
我在<projectname>/Classes/MainViewController.m 中找到了以下存根,我已经用它玩了一下,但还没有解决方案....
- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
{
/* (this does log to the console, but doesn't tell me anything different)
* still: theWebView webView didFailLoadWithError:NSURLErrorDomain -999
*/
NSLog(@"theWebView webView didFailLoadWithError:%@ %d",error.domain,error.code);
/* (this is commented out, it didn't seem to do anything for me) */
if ([error.domain isEqualToString:@"NSURLErrorDomain"] && error.code == -999) {
NSLog(@"theWebView webView caught the error=-999... but returning void doesn't force the page to reload/continue:%@ %d",error.domain,error.code);
return;
}
/* (this was already here, part of PhoneGap) */
return [super webView:theWebView didFailLoadWithError:error];
}
我收到第二条“caught the error=-999”日志消息,但最终我仍然在应用程序上显示白屏。
- 也许某处有一些设置允许重定向回我的应用程序的 URL?
- 也许我需要强制它重新加载我应用的主页?
- 也许我需要一些更优雅的方法来捕获错误,以便它不会停止加载?
- 也许我首先需要有关导致失败的原因的更多信息?
【问题讨论】: