1

I'm using Cordova 5.1.1 and I need to open from my app the App's site on iTunes.

If I do

window.open('https://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&uo=4', "_system","location=no");

I get in Safari "Safari cannot open the page because the address is invalid". My address is valid.

If I try

window.open('itms-apps://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&uo=4', "_system","location=no");

I get "This app is not allowed to query for scheme itms-apps"

I've tried using the encodeurl function and it's the same.

Any idea?

4 Answers4

5

I figured out what the problem was. Further configuring the whitelist plugin with the correct access control tag, the main problem was that I was trying to test the app on the iOS simulator. On the iOS simulator the App Store cannot be opened from the browser as the real OS mainly because the app is not present in the simulator XD.

It's really frustrating to lose time on something like that...

  • How did you configure the whitelist plugin so this worked? I'm having similar issues and can't seem to find the right combination of things to put to make this work. – Johnathan Hok May 06 '16 at 17:31
1

If you use your second option (window.open('itms-apps://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&uo=4', "_system","location=no");)

Then you have to add this on your info.plist file:

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>itms-apps</string>
    </array>

and this in you config.xml

<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
0

Are you trying this on iOS 9? There's privacy change that requires your app to whitelist which other apps it checks for. Cordova seems to implement window.open by running a check to see if that app url exists first.

Joseph Quigley
  • 346
  • 1
  • 12
  • I've tried that and it doesn't work, and the same occurs on IOS8.4 – Rodrigo Fernandez Oct 15 '15 at 20:25
  • Sorry, did not get your response. I've been forgetting to tell people. **iOS9 is [not official support](https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/current-tripping-points.md)** –  Oct 27 '15 at 04:48
0

You are not implementing the full white list, add CSP. Documentation CSP is at bottom.

You can get more details by reading #10 of Top Mistakes by Developers new to Cordova/Phonegap

I Quote

This relatively * NEW * requirement means – to access ANY website or resources on the web, you MUST use the whitelist and the whitelist plugin. This requirement goes into affect, if you are using cordova-android@4.0.0 or better; including cli-5.1.1 and cli-5.2.0. If however, your version is before 4.0.0, let's say 3.5.0 or 3.7.0, then you will not have to add the white-list requirement.

To be clear, the "whitelist" has been around for a bit, but the plugin and requirement is very new. As you would expect, when the "whitelist" was added, the defacto open-access feature was deprecated. Or said another way, the defacto open-access feature was planned and scheduled to be eliminated. This change marks a step in removal of the open-access feature.

In addition, the Content Security Policy (CSP) has caught numerous developers - because it was soooo poorly publicized. Depending on your use and the version of Phonegap you are using, the CSP needs to go in every single HTML page you used, just like you have to wait for 'deviceready'. However, there are cases where it is not needed at all. The documentation is confusing for some, please read it carefully. The documentation is buried in the bottom of many of the latest documentation pages.

Related Links

Phonegap Build Forum: Notes for upgrading to cli-5.1.1 on PGB and now required Whitelist

Community
  • 1
  • 1