I have problem in my app , when I run the app in local host it's working without problem and I can see the channel list but when I try to test the app by physical device it doesn't show anything. I think the problem comes from the method that I'm using to send json data through http.
我的应用有问题,当我在本地主机上运行这个应用时,它没有问题,我可以看到频道列表但是当我尝试用物理设备测试这个应用时,它没有显示任何东西。我认为问题来自我使用http发送json数据的方法。
(function () {
'use strict';
angular.module('testApp').controller('ChannelCtrl', ['$state', 'testApi', ChannelCtrl]);
function ChannelCtrl($state, testApi) {
var vm = this;
myscreenApi.getChannels().then(function(data){
vm.channels = data;
});
vm.selectLeague = function(id){
testApi.setChannelId(id);
$state.go("app.video");
}
};
})();
and this my function to get channeldata
这是我获取频道数据的函数
function getChannels() {
var deferred = $q.defer(),
cacheKey = "leagues",
ChannelsData = null;
if (ChannelsData) {
console.log("Found data inside cache", ChannelsData);
deferred.resolve(ChannelsData);
$window.alert("From Cache");
} else {
$http.get("http://example.com/api/videos/getchannels")
.success(function(data) {
console.log("Received data via HTTP");
self.leaguesCache.put(cacheKey, data);
$window.alert("From HTTP");
deferred.resolve(data);
})
.error(function(dataerr) {
console.log("Error while making HTTP call.");
$window.alert("Error baba daram " + dataerr);
deferred.reject();
});
}
return deferred.promise;
}
when i send data with JSON.parse() , it works right.
当我使用JSON.parse()发送数据时,它正常工作。
vm.channels = JSON.parse('[{"Name":"MyScreen News","ID":46,"Thumbnail":"CB46.jpg","Videos":null}]');
The overall, I used the ASP.NET Web API which is send data by JSON. The App works well in our desktop however the running application can not retrieve data from our host. Moreover, when I inject data in program directly it works in both platform. In addition the ionic config file presented below:
总的来说,我使用了ASP。NET Web API,它通过JSON发送数据。这个应用程序在我们的桌面运行得很好,但是正在运行的应用程序不能从我们的主机中检索数据。此外,当我在程序中直接注入数据时,它在两个平台都能工作。此外,ionic config文件如下:
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
That's all. ;)
这是所有。,)
3 个解决方案
#1
12
If you're using one of the latest versions of cordova you might have to install the cordova plugin whitelist:
如果你正在使用最新版本的cordova,你可能需要安装cordova插件白名单:
cordova plugin add cordova-plugin-whitelist
If you're using IIS Express you might find a few problems.
I've detailed some more explanation here.
如果您正在使用IIS Express,您可能会发现一些问题。我已经在这里详细解释了。
#2
2
Had exactly the same problem while working on a test server. It seems that iOS 9 added a layer of security to their applications by not allowing an app to connect to a server through HTTP rather than HTTPS.
在使用测试服务器时遇到了完全相同的问题。iOS 9似乎通过不允许应用程序通过HTTP而不是HTTPS连接服务器,为其应用程序增加了一层安全性。
To fix this, you have to add This Patch to your info.plist iOS build.
要解决这个问题,您必须将这个补丁添加到您的信息中。plist iOS构建。
Remember that this solution is INSECURE and shouldn't be used in production web services.
请记住,该解决方案是不安全的,不应该在生产web服务中使用。
#3
0
I had the same issue. If you are using cordova higher than 4.0 you will have to run cordova plugin add cordova-plugin-whitelist
我有同样的问题。如果你正在使用高于4.0的cordova,你必须运行cordova插件添加cordova-plugin-whitelist
You can check your cordova version by running cordova -v
你可以通过运行cordova -v来查看你的版本
Happy Coding.
快乐的编码。
#1
12
If you're using one of the latest versions of cordova you might have to install the cordova plugin whitelist:
如果你正在使用最新版本的cordova,你可能需要安装cordova插件白名单:
cordova plugin add cordova-plugin-whitelist
If you're using IIS Express you might find a few problems.
I've detailed some more explanation here.
如果您正在使用IIS Express,您可能会发现一些问题。我已经在这里详细解释了。
#2
2
Had exactly the same problem while working on a test server. It seems that iOS 9 added a layer of security to their applications by not allowing an app to connect to a server through HTTP rather than HTTPS.
在使用测试服务器时遇到了完全相同的问题。iOS 9似乎通过不允许应用程序通过HTTP而不是HTTPS连接服务器,为其应用程序增加了一层安全性。
To fix this, you have to add This Patch to your info.plist iOS build.
要解决这个问题,您必须将这个补丁添加到您的信息中。plist iOS构建。
Remember that this solution is INSECURE and shouldn't be used in production web services.
请记住,该解决方案是不安全的,不应该在生产web服务中使用。
#3
0
I had the same issue. If you are using cordova higher than 4.0 you will have to run cordova plugin add cordova-plugin-whitelist
我有同样的问题。如果你正在使用高于4.0的cordova,你必须运行cordova插件添加cordova-plugin-whitelist
You can check your cordova version by running cordova -v
你可以通过运行cordova -v来查看你的版本
Happy Coding.
快乐的编码。