In the cordova app developed by Phonegap, ajax communication is not possible on iOS 9 series.

Asked 2 years ago, Updated 2 years ago, 94 views

I am developing a cordova app on Phonegap.

As the title suggests, iOS 9 cannot communicate with ajax.
(Ajax communication was possible on iOS10 and iOS11.)

(Not recommended by Apple)
To enable ajax communication, first
*-Info.plist

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>

It would be nice if was described.
(If this understanding is wrong, please point it out.)

in config.xml
<access origin="*"/>
 <allow-intent href="http://*/*"/>
 <allow-intent href="https://*/*"/>
 <allow-intent href="tel:*"/>
 <allow-intent href="sms:*"/>
 <allow-intent href="mailto:*"/>
 <allow-intent href="geo:*"/>
 <allow-navigation href="*://*youtube.com"/>

after describing

\platforms\ios\myapp\myapp-Info.plist

for
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>* youtube.com</key>
    <dict>
      <key>NSExceptionAllowsInsecureHTTPLoads</key>
      <true/>
    </dict>
  </dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

is listed.

However, I still cannot communicate with ajax on iOS9.

How can I do this?
If you know, please reply.

Also, if you need any other information, please let me know.

By the way,

<allow-navigation href="*://*youtube.com"/>

will be able to watch youtube with this app
It must be written.

version

PhonegapBuiid: 8.0.0
cordova-iOS: 4.5.4

ios iphone cordova

2022-09-30 21:33

1 Answers

As I realized after reading the question,
Is the domain of Ajax communication YouTube?
I think it would be better to add the domain of the communication destination.
Also, regarding iOS9, I have listed other settings.
Please refer to it.

<key>NSAppTransportSecurity</key>
<dict>
    <!-- Restrictions in WebView (iOS 10 and above): ATS disabled with true -->
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <!--- Limitations in iTunes (AVFoundationFrameWorks) (iOS 10 and above): ATS disabled on true -->
    <key>NSAllowsArbitraryLoadsInMedia</key>
    <true/>
    <!-- Local resource limits (iOS 10 and above): Allow true to read -->
    <key>NSAllowsLocalNetworking</key>
    <true/>
    <!--Limitations in iOS 9-->
    <!--- Disable exceptionally configured ATS items for the specified domain -->
    <key>NSExceptionDomains</key>
    <dict>
        <key>allow.domain.name</key><!-- exception domain (multiple possible)Optional): Add the domain of the server with Ajax communication -->
        <dict><!---Configuration for the domain directly above-->
            <!--- True unconditionally permits HTTP communication: No other SSL connection, ignoring conflicting certificates -->
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
    <!--- Disable all ATSs for domains configured in "NSExceptionDomains" above -->
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>


2022-09-30 21:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.