[英]ionic failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
While I'm having an ionic app with AngularJS and trying to use it on a real device I get the following output: 当我在AngularJS中使用离子应用程序并尝试在实际设备上使用它时,我得到以下输出:
2015-07-06 17:00:15.760 MyApp[2195:832165] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/D7596A9C-B658-454C-8418-9A61B26091C2/Library/Cookies/Cookies.binarycookies
2015-07-06 17:00:15.803 MyApp[2195:832165] Apache Cordova native platform version 3.8.0 is starting.
2015-07-06 17:00:15.804 MyApp[2195:832165] Multi-tasking -> Device: YES, App: YES
2015-07-06 17:00:15.811 MyApp[2195:832165] Unlimited access to network resources
2015-07-06 17:00:16.460 MyApp[2195:832165] Resetting plugins due to page load.
2015-07-06 17:00:16.911 MyApp[2195:832165] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/47769242-72D0-4907-810A-85332D9564AF/MyApp.app/www/index.html#/home
2015-07-06 17:00:24.247 MyApp[2195:832165] Resetting plugins due to page load.
2015-07-06 17:00:24.259 MyApp[2195:832165] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
2015-07-06 17:04:08.907 MyApp[2195:832165] Resetting plugins due to page load.
2015-07-06 17:04:08.910 MyApp[2195:832165] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
2015-07-06 17:06:19.397 MyApp[2195:832165] Received memory warning. // Here the the app crashes
index.html looks like: index.html看起来像:
<body ng-app="myapp.module">
<ion-pane ng-controller="HomeCtrl" ng-init="check()">
<ion-header-bar class="bar-stable">
<h1 class="title">My ionic app</h1>
</ion-header-bar>
<ion-content class="home-content">
<div class="welcome-message"> Welcome, <span ng-if="!userInfo.isAuthenticated">{{guest}}</span> <span ng-if="userInfo.isAuthenticated">{{userInfo.profile.name}}</span> !</div>
<button type="button" class="button center-block button-positive" ng-show="userInfo.isAuthenticated" ng-click="logout()" name="button">{{logOutTextButton}}</button>
<button type="button" class="button center-block button-positive" ng-hide="userInfo.isAuthenticated" ng-click="login()" name="button">{{loginTextButton}}</button>
</ion-content>
<footer>Footer text</footer>
</ion-pane>
</body>
From the error code "999", it looks like you are loading or reloading a second url before the UIWebView finished loading the first url... 从错误代码“ 999”开始,您似乎在UIWebView完成加载第一个URL之前正在加载或重新加载第二个URL。
therefore, the system cancelled the first one and is trying to load the second url you passed to it... 因此,系统取消了第一个网址,并尝试加载您传递给它的第二个网址...
I got the same error with my Cordova App and it took so many hours to realise the root cause. 我的Cordova应用程序遇到了同样的错误,花了很多小时才找到根本原因。
First thing, I observed that at least "onDeviceReady" event was fired (by putting an alert statement there). 首先,我观察到至少触发了“ onDeviceReady”事件(通过在其中放置警报语句)。 So I suspected that it could be any plugin which might be throwing error inside "onDeviceReady".
因此,我怀疑它可能是“ onDeviceReady”内部可能引发错误的任何插件。 I put all calls to plugin in separate try-catch blocks.
我将对插件的所有调用放在单独的try-catch块中。 This made "onDeviceReady" to be successfully completed and launch app.
这使得“ onDeviceReady”能够成功完成并启动应用程序。 Finally I also found error logs pointing to one plugin.
最后,我还发现了指向一个插件的错误日志。
Hope this helps someone in future. 希望这对以后的人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.