Cordova 2.3. Telephone communications. InAppBrowser url whitelist error.

InAppBrowser in Cordova 2.3.0 does not load URLs as expected. I understand this has to do with the new white urls method and the way they only apply to the main Cordova web interface, not plugins.

I have read an article on how to use your URLs for white plugins, but it is very vague and I am not sure where to add the code they suggest.

The instructions from step 3 in the link above show:

Step 3). Plugin-based network connections are no longer whitelisted. To whitelist your network connections, you must set the "User-Agent" header of your connection to the viewController user agent.

`CDVViewController* vc = ((CDVViewController*)self.viewController);
NSString* userAgent = vc.userAgent;
// then set the User-Agent header of your network connection...`

      

The article does not say where to add this code. I am assuming this goes to MainViewController.m, but I'm not sure. I tried to place it in init function in this file and it didn't work. I also don't know what they mean, "then set the User-Agent header of your network connection ..." Where can I set this?

Has anyone had any success with this? If so, I would like to help. I am really stuck here.

Thank!

+3


source to share


3 answers


This is done in the config.xml file of your phonegap project. Add the following tag between the tag<cordova>

 <access origin="https://example.com" /> 

      



this tag allows any secure requests to example.com

Accessor controls Android whitelist. Domains are assumed to be locked unless otherwise specified

0


source


I posted this here: Phonegap / Cordova 2.3.0 IOS IOS Whitelist Ignored

If you are using storyboards. Add this to your MainViewController or your controller: CDVViewController



- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self = [self init];
    }
    return self;
}

      

0


source


The reason I kept getting webView: didFailLoadWithError was because of passing url without encoding. A regular url like google.com worked fine, but a more complex param url caused a download error. The job for this is to encode the url before calling window.open:

var URL = encodeURI(e.data.url); var ref = window.open(URL, '_blank', 'location=yes');

This allowed me to solve the problem with Cordova 2.5.

0


source







All Articles