您好我已经使用 Cordova 开发了一个应用程序,主要是通过首先测试 IOS 来开发它。我现在已经在 App Store 上发布了该应用程序,现在想将它发布到 google play 商店。
我一直在通过 android studio 测试该应用程序,但无法通过我的登录页面。当我填写并提交表单时,不会发出 AJAX 请求来检查我的登录凭据并让我登录。
我正在使用 android studio profiler 检查是否有请求,但我看不到请求。我在 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'
);
}
}
});
});
任何帮助将不胜感激,谢谢。