嗨,我使用Cordova开发了一个应用程序,主要是通过测试IOS来开发它。我现在已经在app store上发布了应用程序,现在想要将其发布到google play商店。
我一直在通过android studio测试这个应用程序,但无法通过我的登录页面。当我填写表单并提交它时,系统不会发出AJAX请求来检查我的登录凭据并让我登录。
我正在使用android studio分析器检查是否发出了请求,但我看不到。我在Ajax请求之前添加了日志记录,但在表单提交之后添加了日志记录,这是有效的。
在浏览了多个论坛后,我似乎仍然不能让它工作。我已经添加了白名单插件,我已经正确地设置了CORS,因为我必须这样做才能让它在IOS上工作。
这是我的config.xml文件
<?xml version='1.0' encoding='utf-8'?>
<widget id="id" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Title</name>
<description>
description
</description>
<author email="email" href="http://cordova.io">
Team
</author>
<content src="index.html" />
<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="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<preference name="WKWebViewOnly" value="true" />
<config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist">
<string>Background location tracking is required to notify you when you enter a location offering deals</string>
</config-file>
<config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
<string>Background location tracking is required to notify you when you enter a location offering deals</string>
</config-file>
<config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
<string>Background location tracking is required to notify you when you enter a location offering deals</string>
</config-file>
<config-file parent="NSMotionUsageDescription" target="*-Info.plist">
<string>Device motion updates help determine when the device is stationary so the app can save power by turning off location-updates</string>
</config-file>
</platform>
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#262262" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="orientation" value="portrait" />
<preference name="DisallowOverscroll" value="true" />
<plugin name="cordova-plugin-console" spec="~1.1.0" />
<plugin name="cordova-plugin-statusbar" spec="^2.4.3" />
<plugin name="cordova-plugin-dialogs" spec="^2.0.2" />
<plugin name="cordova-plugin-wkwebview-engine" spec="~1.2.1" />
<plugin name="cordova-plugin-wkwebview-file-xhr" spec="~2.1.4" />
<plugin name="cordova-plugin-geofence" spec="^0.7.0" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-background-geolocation-lt" spec="^3.7.0">
<variable name="BACKGROUND_MODE_LOCATION" value="<string>location</string>" />
</plugin>
<plugin name="cordova-plugin-cocoalumberjack" spec="~0.0.4" />
<plugin name="cordova-plugin-qrscanner" spec="~3.0.1" />
<plugin name="cordova-plugin-geolocation" spec="~4.0.2" />
<plugin name="cordova-plugin-local-notification" spec="~0.9.0-beta.2" />
</widget>下面是似乎没有发出任何请求的AJAX代码。
$("#login_form").submit(function(e) {
e.preventDefault()
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: 'login-url',
data: form.serialize(), // serializes the form's elements.
success: function(data) {
storage.setItem('access_token', data.access_token) // Pass a key name and its value to add or update that key.
window.location.href = "deals.html";
},
error: function(httpObj, textStatus) {
if (httpObj.status == 401) {
navigator.notification.alert(
'Please try again using the correct credentials.',
alertDismissed,
'Incorrect Details',
'Try Again'
);
}
}
});
});任何帮助都会非常感谢,谢谢。
发布于 2020-07-10 20:00:20
在config.xml中,在<platform name="android">下添加以下标记
<config-file target="app/src/main/AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</config-file> 然后再次为android构建或运行,并检查您是否可以访问互联网
https://stackoverflow.com/questions/62831555
复制相似问题