I try to use Angularjs http service to call my PHP API. Everything working fine in Browser. But, when I test it on my Android Phone, it will not work.
My Issue:
In Android PhoneGap Application, Whenever I trigger the Angularjs http service it will always trigger the function (error)
even when the Mobile is connected with Internet.
I have try look this but their solution aren't working:
I also have ensure the Phonegap config.xml
has allowed Internet Permission Access with:
<access allows-arbitrary-loads-in-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
However it is still not Working.
My Question:
config.xml
, is there any other configuration have to be made to allow PhoneGap Mobile Application to access the Internet?Angularjs code:
$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
$http({
method: 'POST',
data: {
'email' : $scope.email,
'password' : $scope.password,
},
url: 'https://unsurfaced-cross.000webhostapp.com/PGLogin.php'
}).then(function (response){
$scope.users = response.data;
if(response.data[0]=="LOGIN"){
alert("Successful Login");
$window.location.href = './homepage.html';
}else{
alert("Login Failed. Incorrect Email or Password.");
}
},function (error){
alert("Please ensure You are connected to Internet.");
});
seem like actually I just didn't install the whitelist
plugin, for my case the whitelist
plugin didn't installed by Default.
Since I was using PhoneGap, instead of using command like cordova-plugin-whitelist@latest
, cordova create
, cordova plugin add cordova-plugin-whitelist
or etc.
I should use: phonegap plugin add cordova-plugin-whitelist
After install the Whitelist Plugin, everything working fine.
So,