Error: Whitelist rejection in Phonegap - iphone

I'm new to mobile development. I'm using Phonegap/Cordova to create a cross-platform app. My code works well on Android but when I'm porting it to iPhone it's showing an error:
[143:2003] ERROR whitelist rejection: url="abc"
Now can I overcome this problem?

Notice: This answer only applies for PhoneGap version 1.x and below. From version 2.x onwards, whitelist configuration is done via cordova.xml.
You have to add allowed URLs into PhoneGap.plist's (or Cordova.plist) ExternalHosts array.
For example, if you want to allow access to this URL http://www.myhost.com/path/file, then add www.myhost.com as a new entry to ExternalHosts array.
If you want to allow access to content on all the subdomain of Google (e.g. maps.google.com, mails.google.com), you can add *.google.com as a new entry to ExternalHosts array.
I am not sure why you get "abc" in the link, though. Do you have "abc" as a link to anything? Is it URI fragment?

In PhoneGap 3.0, you need to edit config.xml in Project folder (note: not the www/config.xml)
<access origin="*" />

In PhoneGap 3.0, you need to edit www/config.xml, and add/edit <access> tags. For example, if you want to allow everything, change the tag to:
<access origin="*" />

You can add this following code in Cordova.plist file:
<key>ExternalHosts</key>
<array>
<string>*.facebook.com</string>
</array>
With *.facebook.com as the domain name, you can use two different sub-domains.

You will have to Domain Whitelist so you can access outside domains such as http://google.com.
In iOS (Cordova > 3.0.0), the whitelisting rules are found in AppName/config.xml and declared with the element <access origin="..." />
You can also use wildcards to declare domains. For example, to allow access to all subdomains and TLDs (.com, .net, etc) of Google, use *.google.*
Reference: Domain Whitelist Guide

Even I got the same issue... I fixed it in the below way..In cordova.plist--> under ExternalHosts array menu, add an item as * or .. So it allows all the external links... if u have to mention one by one mention it as .facebook.,*.google.* etc.

This is because phonegap won't take external urls .For phonegap older versions below 2.x we need to set url in cordova.plist like this.
ex:*.google.co.in(u can put your url after *. this) and OpenAllWhitelistURLsInWebView---to ---YES.

Related

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

How can I accessing a 3rd party plugin (phonegap-facebook-plugin) in Intel XDK?

I am importing the Wizcorp phonegap-facebook-plugin using the intelxdk.config.additions.xml file with this code:
<intelxdk:plugin intelxdk:name="com.phonegap.plugins.facebookconnect" intelxdk:value="https://github.com/Wizcorp/phonegap-facebook-plugin/">
<intelxdk:param intelxdk:name="APP_ID" intelxdk:value="MyActualAppID" />
<intelxdk:param intelxdk:name="APP_NAME" intelxdk:value="fizz points" />
</intelxdk:plugin>
I've read and understand that I will not be able to test this 3rd party plugin in the emulator, or via the test or debug tabs, so I've created a test build for Android.
Based on the documentation, I believe I am supposed to reference this API via calls to the facebookConnectPlugin, such as:
facebookConnectPlugin.login(["publish_stream", "publish_actions", "offline_access"],
fbLoginSuccess,
function (error) { alert("There was an error: " + error) });
However, I know that in the built app, as in the emulator, the facebookConnectPlugin is not defined, because I get an alert based on the following block:
if (typeof facebookConnectPlugin != 'undefined'){
// do stuff
} else {
alert("FacebookConnectPlugin Not Defined");
}
I assume this is because I need to include the 3rd party library in my code in addition to including it in my project where suggested by the helpful comments, something like:
<!-- Most third-party libraries should go here. References (below) are just examples to give you the general idea... -->
<!-- <script src="lib/mc/hammer.js"></script> -->
Initially, I didn't know the path where the 3rd party library is ultimately located in the package after the build tool retrieves it. But I was told that I could change the .apk extension to .zip extract and explore the contents.
I did this, and found that the library was stored in:
www/plugins/com.phonegap.plugins.facebookconnect/www/phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js
So I added the following to my index.html file:
<script src="plugins/com.phonegap.plugins.facebookconnect/www/phonegap/plugin/facebookConnectPlugin/facebookConnectPlugin.js"></script>
However, when built, my test to see if the FacebookConnectPlugin is defined still fails.
Thanks!
Noah
[I've essentially asked the same question on the Intel forums here: https://software.intel.com/en-us/forums/topic/536743 . No solution yet, but if I get one I will post it here.]
You need to build your app and install it on your device to test the WizCorp Facebook plugin. Please make sure you follow the instructions for configuring your app on Facebook.
note the Emulator (simulator) does not support third party plugins as you have noted. Same for using App Preview to test. You must build your app in the cloud.
thanks,
Ian
Are you accessing the facebookConnectPlugin object from inside device ready event?
document.addEventListener("intel.xdk.device.ready",function() {
// try in here
}, false);
It could be undefined if you are accessing it from outside as the plugin is not ready to be used yet.

Correct way to submit a phonegap/jQM form.

very new at this. Could someone tell me what is the best method of submitting a form when using phonegap and JMQ? What I want to be able to do is passing the form data to a php file and then having the results passed back into app so that the user isnt directly accessing the php file at any point.
I found the following page link which basically does what I want but I keep getting "Origin null is not allowed by Access-Control-Allow-Origin" when testing out the code. So I'm guessing this will only work if the app is located on a server also?
Any happy would be great. thank <3
To test your solution on the computer you need to launch chrome from the terminal with the argument --disable-web-security. See this answer: Disable same origin policy in Chrome
In your Phonegap application you add a line of code to your config.xml in the www-folder: <access origin="*.yourdomain.com" />. Build, and you are now allowed to request all domains and subdomains from yourdomain.com. For more details on whitelisting see http://docs.phonegap.com/en/3.0.0/guide_appdev_whitelist_index.md.html#Domain%20Whitelist%20Guide
You are not able to make post through the local files, so Yes, you need to have it running in a Web Server.
But if you deploy your application, it should work either in a emulator or in your device.

No such Directory Error >

i am using in my code this protocol:
#import "AdMobDelegateProtocol.h"
but i am facing no such file or directory found ??
help needed.
This error shows AdMobDelegateProtocol.h not present in your app bundle. either it need any kind of reference if you use this from any code present at net or you missing to include any framework or it also may possible you create any kind of typo. not more than this
Pls check if the file is present in the project folder or tree in the correct destination. This indicates that there is no such file or is missing in the specified folder/destination
From your comments I see you use AdWhirl.
If you want to use AdMob with AdWhirl you have to add the AdMob framework to your project.
There are no Ad frameworks included in AdWhirl. You have to add them to your project. AdWhirl just uses them, but you have to add them.
You can find the AdMob SDK and install instructions on the admob website.

How to share keychain data between iOS applications

I am describing a problem for which it took me quite some time to learn the answer.
The "GenericKeychain" example is a good start at providing a wrapper for sharing keychain data between applications when using the accessGroup in the init.
However, implementing this in my app yielded an obscure error code (which took forever to locate) -25243, which means: No access control.
I ran Apple's example app (GenericKeychain) on my iPad only to get the same error. Huh?
Does Apple's documentation fail to deliver on what is necessary to accomplish this?
After some (a lot of) digging throughout the web, I found the answer. The access Group that you use when constructing your KeychainItemWrapper class must ALSO be specified in each of your application's Entitlements.plist file in the "keychain-access-groups" section.
It seems almost obvious now that I see "keychain-access-groups". However, I had no idea to even look there. Hope this helps others.
Actually it's not hard to do. Please follow the steps.
App1:
Open your App's target Capabilities and enable KeyChain Sharing.
Add a identifier. (eg : com.example.sharedaccess)
Add "UICKeyChainStore" to your project.
Be sure you have a team id added to your App1 project.
Add Security.framework to your App1 project.
And add these codes to somewhere you need.
[UICKeyChainStore setString:#"someValue" forKey:#"someKey" service:#"someService"];
App2:
Open your App's target Capabilities and enable KeyChain Sharing.
Add a identifier. (eg : com.example.sharedaccess)
Add "UICKeyChainStore" to your project.
Be sure you have a team id added to your App2 project.
Add Security.framework to your App2 project.
And add these codes to somewhere you need.
NSString *string = [UICKeyChainStore stringForKey:#"someKey" service:#"someService"];
Your TeamIDs should be same for both projects.
I tried these steps on a real iPhone device.
I also tried these steps with Automatic and iOs Development provisioning profile.
My apps' bundle identifiers were like that : com.example.app1, com.example.app2.