whitelist rejection in phonegap compilation
The solution is to Whitelist (allow) the host to be accessible via phonegap, to accomplish it
In Phonegap.plist file,
Add new row to External Host (Key value pair)
for value, put your host name : (SERVER.COM).
e.g.
1) ERROR whitelist rejection: url('http://localhost:XXXX/myproject/index')
Type: localhost in value column for for External Host
2) ERROR whitelist rejection: url('http://myserver.com/dashboard/mobilews.php?')
Type: myserver in value column for External Host
May be putting "*" , the asterisk as a value of the host that references an external URL , will do the trick. but not safe.
Add new row to External Host (Key value pair)
for value, put your host name : (SERVER.COM).
e.g.
1) ERROR whitelist rejection: url('http://localhost:XXXX/myproject/index')
Type: localhost in value column for for External Host
2) ERROR whitelist rejection: url('http://myserver.com/dashboard/mobilews.php?')
Type: myserver in value column for External Host
May be putting "*" , the asterisk as a value of the host that references an external URL , will do the trick. but not safe.
hope this helps, It works great for us :)
see my comments below for more info, as phonegap is cordova now!
see my comments below for more info, as phonegap is cordova now!
Thanks! :) it worked perfetly after adding .com and a star prior the hostname.
ReplyDeleteI have tried all the difference versions of External hosts but still do NOT get around this Whitelist rejection. (ERROR whitelist rejection: )
ReplyDeleteAre there any unknown issues in XCode 3.2.6 and PhoneGap 1.4.1 that explains this.
Tried *.*, *[domainname].*, *, *.[domainname].com
The simulator (iOS4.3) can connect to the internet.. it is just my app that cannot.
Doing a basic Jquery Ajax call.
hmm, just try to put SERVER_HOST_NAME of which server host you are trying to connect. e.g. "google" for http://google.com
ReplyDeleteIf you still have trouble:
Better will be to send the code to me, so that I can look into.
Feel free to reach me via Skype "garg.praveen" or email "er.praveengarg@gmail.com".
--Best
Praveen
I found the problem. In the Xcode editor it is easy to add the ExternalHosts as an extra row, and not as a subset of the External Hosts node...
ReplyDeleteI should have edited the file with a text editor rather.
Great! Thanks for sharing..
ReplyDeletebtw, if we need to allow multiple hosts to be connected And we want to add only specific host names (NOT any of the external hosts i.e. *) THEN we should add them as a subset of the External Hosts node.
ReplyDeleteHope! It make sense.
Phonegap is actually the part of Apache foundation now, and they named it as Cordova (intially apache callback). so there shall be a Cordova.plist now. and we need to make changes in that plist.
ReplyDeleteAs per the documentation.
The latest (Cordova) code has the new white-list feature. If you are referencing external hosts, you will have to add the host in Cordova.plist under the "ExternalHosts" key. Wildcards are okay. So if you are connecting to "http://'www.mydomain.com", you have to
add "mydomain.com" to the list (or use the wildcard "*.mydomain.com" which will match subdomains as well).
Hello Sir, Really your blog shorted out my problem. Since the very beginning day I was facing this error in Cordova framework. Thanks a lot!!!
ReplyDeletethanks a lot for this blog. thanks a ton..dinesh
ReplyDeleteGot a question, I'm running Xcode 4.3.2 now with 1.7.0 PhoneGap. I've tried all versions of this and still it isn't working, due to the upgraded versions (started at this version) is there a different way of going about this? Also, when adding a new value does the Type need to be "String"?
ReplyDeleteThanks,
This comment has been removed by the author.
ReplyDelete@Billy,
ReplyDeleteCan you please send that plist via email/dropbox? My email id is (er.praveengarg@gmail.com)
Yes, you need to Add host value as a String node (chile node) of ExternalHost (parent node of type array)...
Good work, extremely helpful!
ReplyDeleteThanks ! That helped !
ReplyDeleteHi nice to meet you Praveen.I still cant fix it.let say my url is not start with "www" .eg:"http://abc.abc.com" what shall i put i the value string.i try add *abc.abc.com/abc.abc.com/abc.com still dint work. please help me out of this.
ReplyDeletethank you
Try
DeleteFIRST:
*.abc.com Here abc is main domain name.
SECOND:
*.* (in case, you see some challenge in FIRST case)
Hope this will solve your issue.
--Best
Praveen