AJAX calls don't work on phonegap apk build

我是研究僧i 提交于 2020-01-05 07:18:08

问题


When using build.phonegap all of my ajax calls dont work, it works in website form and when using the app to connect to the server, but once i build the AJAX calls go through, but don't update on the app (if I click to the website i see the changes made on the apk, but not on the phone)

My config.xml file is

<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android = "http://schemas.android.com/apk/res/android">
    <name>Carello</name>
    <description>
       Carello
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <access origin="*" />
<plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/jrontend/phonegap-plugin-barcodescanner" />

    <engine name="browser" spec="~5.0.4" />
    <engine name="android" spec="^7.1.4" />
    <plugin name="cordova-plugin-whitelist" spec="1.3.3" />
    <config-file target="AndroidManifest.xml" parent="/*" mode="merge">
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>
    <access origin="*" launch-external="yes" />
    <content src="index.html" />
    <allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
    <gap:platform name="android" />
</widget>

I also have

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' data: gap: 'unsafe-eval'; style-src * 'self' 'unsafe-inline';  connect-src * ;  script-src * 'self' 'unsafe-inline';  media-src *">

in my html files.


回答1:


Add Below permission in AndroidManifest.xml file.

<uses-permission android:name="android.permission.INTERNET" />



回答2:


Try to add this to you'r config.xml :

<allow-intent href="*" />
<allow-navigation href="*" />

Be carefull, it's only for debug, when you'r application was ready for production, you have to restrict this with replace * by you'r domain.



来源:https://stackoverflow.com/questions/56178450/ajax-calls-dont-work-on-phonegap-apk-build

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