Http and Https calls not working after Cordova upgrade

╄→尐↘猪︶ㄣ 提交于 2021-01-29 18:23:26

问题


I built an app by using Cordova and it's in production for more than years. Recently few days back I upgraded my Cordova version from 9.x to 10.x. After upgrade, Http and Https calls are not working. I am using Axios to make API calls.

After I did research on this issue I found some solutions to add cordova-plugin-wkwebview-file-xhr. I did but no luck. I placed my config.xml file for the reference.

Getting the following error while making API calls

nativeXHR: Invalid url scheme null

It would be appreciated if anyone can help?

<widget xmlns="http://www.w3.org/ns/widgets" 
    xmlns:gap="http://phonegap.com/ns/1.0" id="##appId##" ios-CFBundleVersion="101" version="##version##" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <name>##appName##</name>
    <description>##appDescription##</description>
    <author href="" email=""></author>

    <plugin name="cordova-plugin-whitelist" spec="1.3.0" />
    <plugin name="cordova-plugin-file" spec="4.0.0"/>
    <plugin name="cordova-plugin-file-opener2" spec="2.2.1"/>
    <plugin name="cordova-plugin-browser" spec="1.0.1"/>
    <plugin name="cordova-plugin-3dtouch" spec="1.3.5"/>
    <plugin name="cordova-plugin-touch-id" spec="3.3.1" />
    <plugin name="cordova-plugin-android-fingerprint-auth" spec="1.5.0" />
    <plugin name="cordova-plugin-secure-storage-echo" spec="5.0.0"/>
    <plugin name="cordova-plugin-device" spec="1.1.3" />
    <plugin name="cordova-plugin-inappbrowser" spec="4.0.0" />
    <plugin name="cordova-plugin-network-information" spec="1.3.0" />
    <plugin name="cordova-plugin-splashscreen" spec="5.0.1" />
    <plugin name="cordova-plugin-statusbar" spec="2.4.1" />
    <plugin name="cordova-plugin-nativestorage" spec="2.3.2" />
    <plugin name="de.appplant.cordova.plugin.printer" spec="0.7.3" />
    <plugin name="cordova-plugin-app-launcher" spec="0.4.0"/>
    <plugin name="phonegap-plugin-push" spec="2.3.0">
        <param name="SENDER_ID" value="819721619677" />
    </plugin>
    <plugin name="cordova-plugin-camera" spec="2.4.1">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="App would like to access the camera." />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="App would like to access the library." />
    </plugin>
    <plugin name="cordova-plugin-dialogs" spec="1.3.4"/>
    <plugin name="cordova-plugin-request-location-accuracy" spec="2.2.3" />
    <plugin name="cordova-plugin-geolocation" spec="2.4.3" />
    <plugin name="@grandhi/cordova-diagnostic-plugin" spec="1.0.1"/>
    <plugin name="cordova-android-support-gradle-release">
        <variable name="ANDROID_SUPPORT_VERSION" value="28.0.0"/>
    </plugin>
    <plugin name="cordova-plugin-apprate" spec="1.4.0" />
    <plugin name="phonegap-plugin-media-stream" spec="1.2.1" />
    <plugin name="cordova-plugin-tts" spec="0.2.3" />
    <plugin name="cordova-plugin-wkwebview-file-xhr" spec="3.0.0" />
    <preference name="cordova.plugins.diagnostic.modules" value="LOCATION" />


    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="1500" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="orientation" value="default"/>
    <preference name="fullscreen" value="false"/>
    <preference name="target-device" value="universal"/>
    <preference name="webviewbounce" value="false"/>
    <preference name="UIWebViewBounce" value="false"/>
    <preference name="prerendered-icon" value="true"/>
    <preference name="stay-in-webview" value="true"/>
    <preference name="ios-statusbarstyle" value="default"/>
    <preference name="detect-data-types" value="true"/>
    <preference name="exit-on-suspend" value="false"/>
    <preference name="auto-hide-splash-screen" value="true"/>
    <preference name="FadeSplashScreen" value="false" />
    <preference name="FadeSplashScreenDuration" value="0" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="EnableViewportScale" value="true"/>
    <preference name="MediaPlaybackRequiresUserAction" value="false"/>
    <preference name="AllowInlineMediaPlayback" value="false"/>
    <preference name="BackupWebStorage" value="cloud"/>
    <preference name="TopActivityIndicator" value="gray"/>
    <preference name="KeyboardDisplayRequiresUserAction" value="true"/>
    <preference name="HideKeyboardFormAccessoryBar" value="false"/>
    <preference name="SuppressesIncrementalRendering" value="false"/>
    <preference name="android-minSdkVersion" value="22"/>
    <preference name="android-installLocation" value="internalOnly"/>
    <preference name="ErrorUrl" value=""/>
    <preference name="BackgroundColor" value="0x000000"/>
    <preference name="KeepRunning" value="true"/>
    <preference name="LoadingDialog" value=","/>
    <preference name="LoadUrlTimeoutValue" value="20000"/>
    <preference name="disable-cursor" value="false"/>
    <preference name="StatusBarOverlaysWebView" value="false" />
    <preference name="StatusBarBackgroundColor" value="#000000" />
    <preference name="StatusBarStyle" value="lightcontent" />
    <preference name="UIWebViewDecelerationSpeed" value="fast" />
    <preference name="android-build-tool" value="gradle" />
    <preference name="android-targetSdkVersion" value="28" />

    <gap:platform name="ios"/>
    <gap:platform name="android"/>

    <icon src="images/ios/icons/icon-29.png" gap:platform="ios" width="29" height="29"/>
    <icon src="images/ios/icons/icon-40.png" gap:platform="ios" width="40" height="40"/>
    <icon src="images/ios/icons/icon-48.png" gap:platform="ios" width="48" height="48"/>
    <icon src="images/ios/icons/icon-50.png" gap:platform="ios" width="50" height="50"/>
    <icon src="images/ios/icons/icon-57.png" gap:platform="ios" width="57" height="57"/>
    <icon src="images/ios/icons/icon-58.png" gap:platform="ios" width="58" height="58"/>
    <icon src="images/ios/icons/icon-60.png" gap:platform="ios" width="60" height="60"/>
    <icon src="images/ios/icons/icon-64.png" gap:platform="ios" width="64" height="64"/>
    <icon src="images/ios/icons/icon-72.png" gap:platform="ios" width="72" height="72"/>
    <icon src="images/ios/icons/icon-76.png" gap:platform="ios" width="76" height="76"/>
    <icon src="images/ios/icons/icon-80.png" gap:platform="ios" width="80" height="80"/>
    <icon src="images/ios/icons/icon-87.png" gap:platform="ios" width="87" height="87"/>
    <icon src="images/ios/icons/icon-100.png" gap:platform="ios" width="100" height="100"/>
    <icon src="images/ios/icons/icon-114.png" gap:platform="ios" width="114" height="114"/>
    <icon src="images/ios/icons/icon-120.png" gap:platform="ios" width="120" height="120"/>
    <icon src="images/ios/icons/icon-144.png" gap:platform="ios" width="144" height="144"/>
    <icon src="images/ios/icons/icon-152.png" gap:platform="ios" width="152" height="152"/>
    <icon src="images/ios/icons/icon-167.png" gap:platform="ios" width="167" height="167"/>
    <icon src="images/ios/icons/icon-320.png" gap:platform="ios" width="320" height="320"/>
    <icon src="images/ios/icons/icon-1024.png" gap:platform="ios" width="1024" height="1024"/>

    <icon src="images/android/icons/ldpi.png" gap:platform="android" gap:density="ldpi"/>
    <icon src="images/android/icons/mdpi.png" gap:platform="android" gap:density="mdpi"/>
    <icon src="images/android/icons/hdpi.png" gap:platform="android" gap:density="hdpi"/>
    <icon src="images/android/icons/xhdpi.png" gap:platform="android" gap:density="xhdpi"/>
    <icon src="images/android/icons/xxhdpi.png" gap:platform="android" gap:density="xxhdpi"/>
    <icon src="images/android/icons/xxxhdpi.png" gap:platform="android" gap:density="xxxhdpi"/>
    <icon src="images/icon-64.png"/>

    <splash src="images/ios/splash/Default@2x~universal~anyany.png" />

    <gap:splash src="images/android/splash/splash200x320.png" gap:platform="android" gap:density="ldpi"/>
    <gap:splash src="images/android/splash/splash320x480.png" gap:platform="android" gap:density="mdpi"/>
    <gap:splash src="images/android/splash/splash480x800.png" gap:platform="android" gap:density="hdpi"/>
    <gap:splash src="images/android/splash/splash720x1280.png" gap:platform="android" gap:density="xhdpi"/>
    <gap:splash src="images/android/splash/splash960x1600.png" gap:platform="android" gap:density="xxhdpi"/>
    <gap:splash src="images/android/splash/splash1280x1920.png" gap:platform="android" gap:density="xxxhdpi"/>

    <gap:splash src="images/android/splash/splash320x200.png" gap:platform="android" gap:density="ldpi"/>
    <gap:splash src="images/android/splash/splash480x320.png" gap:platform="android" gap:density="mdpi"/>
    <gap:splash src="images/android/splash/splash800x480.png" gap:platform="android" gap:density="hdpi"/>
    <gap:splash src="images/android/splash/splash1280x720.png" gap:platform="android" gap:density="xhdpi"/>
    <gap:splash src="images/android/splash/splash1600x960.png" gap:platform="android" gap:density="xxhdpi"/>
    <gap:splash src="images/android/splash/splash1920x1280.png" gap:platform="android" gap:density="xxxhdpi"/>

    <gap:splash src="splash.png"/>

    <access origin='*' minimum-tls-version='TLSv1.1' requires-forward-secrecy='true' requires-certificate-transparency='true' />

    <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="http://*/*" />
    <allow-navigation href="https://*/*" />
    <allow-navigation href="data:*" />

    <platform name="android">
        <allow-intent href="market:*" />
        <resource-file src="google-services.json" target="app/google-services.json" />
        <preference name="DisallowOverscroll" value="true"/>
        <config-file parent="/manifest/application" target="AndroidManifest.xml" 
            xmlns:android="http://schemas.android.com/apk/res/android">
            <provider android:authorities="${applicationId}.opener.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
                <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
            </provider>
        </config-file>
        <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/>
        </config-file>

        <config-file parent="/manifest/application" target="AndroidManifest.xml">
            <service android:name="com.adobe.phonegap.push.FCMService">
                <intent-filter>
                    <action android:name="com.google.firebase.MESSAGING_EVENT"/>
                </intent-filter>
            </service>
        </config-file>

        <icon src="images/android/icons/ldpi.png" density="ldpi"/>
        <icon src="images/android/icons/mdpi.png" density="mdpi"/>
        <icon src="images/android/icons/hdpi.png" density="hdpi"/>
        <icon src="images/android/icons/xhdpi.png" density="xhdpi"/>
        <icon src="images/android/icons/xxhdpi.png" density="xxhdpi"/>
        <icon src="images/android/icons/xxxhdpi.png" density="xxxhdpi"/>

        <splash src="images/android/splash/splash200x320.png" density="port-ldpi"/>
        <splash src="images/android/splash/splash320x480.png" density="port-mdpi"/>
        <splash src="images/android/splash/splash480x800.png" density="port-hdpi"/>
        <splash src="images/android/splash/splash720x1280.png" density="port-xhdpi"/>
        <splash src="images/android/splash/splash960x1600.png" density="port-xxhdpi"/>
        <splash src="images/android/splash/splash1280x1920.png" density="port-xxxhdpi"/>

        <splash src="images/android/splash/splash320x200.png" platform="android" density="land-ldpi"/>
        <splash src="images/android/splash/splash480x320.png" platform="android" density="land-mdpi"/>
        <splash src="images/android/splash/splash800x480.png" platform="android" density="land-hdpi"/>
        <splash src="images/android/splash/splash1280x720.png" platform="android" density="land-xhdpi"/>
        <splash src="images/android/splash/splash1600x960.png" platform="android" density="land-xxhdpi"/>
        <splash src="images/android/splash/splash1920x1280.png" platform="android" density="land-xxxhdpi"/>
        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <preference name="DisallowOverscroll" value="true"/>
        <preference name="KeychainAccessibility" value="WhenUnlocked"/>
        <preference name="InterceptRemoteRequests" value="all" />
        <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

        <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
            <string>This app uses the camera to upload your profile photo and take pictures of attachments.</string>
        </edit-config>

        <!-- NSAllowsArbitraryLoads -->
        <icon src="images/ios/icons/icon-29.png" width="29" height="29"/>
        <icon src="images/ios/icons/icon-40.png" width="40" height="40"/>
        <icon src="images/ios/icons/icon-48.png" width="48" height="48"/>
        <icon src="images/ios/icons/icon-50.png" width="50" height="50"/>
        <icon src="images/ios/icons/icon-57.png" width="57" height="57"/>
        <icon src="images/ios/icons/icon-58.png" width="58" height="58"/>
        <icon src="images/ios/icons/icon-60.png" width="60" height="60"/>
        <icon src="images/ios/icons/icon-64.png" width="64" height="64"/>
        <icon src="images/ios/icons/icon-72.png" width="72" height="72"/>
        <icon src="images/ios/icons/icon-76.png" width="76" height="76"/>
        <icon src="images/ios/icons/icon-80.png" width="80" height="80"/>
        <icon src="images/ios/icons/icon-87.png" width="87" height="87"/>
        <icon src="images/ios/icons/icon-100.png" width="100" height="100"/>
        <icon src="images/ios/icons/icon-114.png" width="114" height="114"/>
        <icon src="images/ios/icons/icon-120.png" width="120" height="120"/>
        <icon src="images/ios/icons/icon-144.png" width="144" height="144"/>
        <icon src="images/ios/icons/icon-152.png" width="152" height="152"/>
        <icon src="images/ios/icons/icon-167.png" width="167" height="167"/>
        <icon src="images/ios/icons/icon-320.png" width="320" height="320"/>
        <icon src="images/ios/icons/icon-1024.png" width="1024" height="1024"/>

        <splash src="images/ios/splash/Default@2x~universal~anyany.png" />

        <config-file parent="NSBluetoothAlwaysUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app requires constant Bluetooth access to function properly</string>
        </config-file>

        <edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
            <string>need microphone access to record sounds</string>
        </edit-config>

        <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
            <string>This app requires your location to clock in or out.</string>
        </edit-config>

        <feature name="CDVWKWebViewEngine">
          <param name="ios-package" value="CDVWKWebViewEngine" />
        </feature>

    </platform>
</widget>```

来源:https://stackoverflow.com/questions/64329705/http-and-https-calls-not-working-after-cordova-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!