我已经构建了一个混合Phonegap应用程序。我是Android用户,所以我在KitKat上进行了测试,但它确实有效。我已将它发送给我的客户,他是iPhone的用户,他给我发了这个截图:
的Config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.swapco.swapco" 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>SwapCo</name>
<description>
SwapCo
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
SwapCo
</author>
<content src="index.html" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="10" />
<preference name="android-installLocation" value="auto" />
<gap:plugin name="org.apache.cordova.battery-status" />
<gap:plugin name="org.apache.cordova.camera" />
<gap:plugin name="org.apache.cordova.media-capture" />
<gap:plugin name="org.apache.cordova.console" />
<gap:plugin name="org.apache.cordova.contacts" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.device-motion" />
<gap:plugin name="org.apache.cordova.device-orientation" />
<gap:plugin name="org.apache.cordova.dialogs" />
<gap:plugin name="org.apache.cordova.file" />
<gap:plugin name="org.apache.cordova.file-transfer" />
<gap:plugin name="org.apache.cordova.geolocation" />
<gap:plugin name="org.apache.cordova.globalization" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.media" />
<gap:plugin name="org.apache.cordova.network-information" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<gap:plugin name="org.apache.cordova.vibration" />
<icon src="icon.png" />
<icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icon/android/icon.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icon/android/icon.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icon/android/icon.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icon/android/icon.png" />
<icon gap:platform="blackberry" src="www/res/icon/blackberry/icon-80.png" />
<icon gap:platform="blackberry" gap:state="hover" src="www/res/icon/blackberry/icon-80.png" />
<icon gap:platform="ios" height="57" src="www/res/icon/ios/icon.png" width="57" />
<icon gap:platform="ios" height="72" src="www/res/icon/ios/icon.png" width="72" />
<icon gap:platform="ios" height="114" src="www/res/icon/ios/icon.png" width="114" />
<icon gap:platform="ios" height="144" src="www/res/icon/ios/icon.png" width="144" />
<icon gap:platform="webos" src="www/res/icon/webos/icon-64.png" />
<icon gap:platform="winphone" src="www/res/icon/windows-phone/icon-48.png" />
<icon gap:platform="winphone" gap:role="background" src="www/res/icon/windows-phone/icon-173-tile.png" />
<gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="www/res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="www/res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="www/res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="www/res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="www/res/screen/blackberry/screen-225.png" />
<gap:splash gap:platform="ios" height="480" src="www/res/screen/ios/screen-iphone-portrait.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="www/res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1136" src="www/res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="www/res/screen/ios/screen-ipad-portrait.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="www/res/screen/ios/screen-ipad-landscape.png" width="1024" />
<gap:splash gap:platform="winphone" src="www/res/screen/windows-phone/screen-portrait.jpg" />
<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="^4.0.0" />
<engine name="ios" spec="^3.8.0" />
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
</feature>
<gap:config-file platform="android" parent="/manifest">
<application android:debuggable="true" />
</gap:config-file>
</widget>
的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>XXX</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/style.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="row">
<div class=" col-xs-4 col-xs-push-4 col-sm-4 col-sm-push-4 col-md-2 col-md-push-5">
<img src="images/logo.png" class="img-responsive center-block logo">
</div>
</div>
<div class="row">
<div class=" col-xs-12 col-sm-8 col-sm-push-2 col-md-4 col-md-push-4">
<br />
<h2 class="text-center white">Welcome!</h2>
<p class="text-center white">Selling made simple.</p>
<div class="input-area" style="margin-top:60px">
<input id="username" type="text">
<span class="icon"><i class="fa fa-user"></i> </span>
</div>
<div class="input-area">
<input id="password" type="password">
<span class="icon"><i class="fa fa-key"></i> </span>
</div>
</div>
<div class="bottom-buttons">
<button type="button" onclick="authenticate()" class="btn signin pull-left">SIGN IN</button>
<a href="signup.html"><button type="button" class="btn signup pull-right">SIGN UP</button></a>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="js/index.js"></script>
</body>
</html>
我有一个苹果新手,非常欢迎任何评论。顺便说一下,我正在为iOS版本使用开发证书,我已将他的iPhone与它们联系起来。
答案 0 :(得分:0)
修改强>
以下是我注意到的一些事情:
<script type="text/javascript" src="cordova.js"></script>
version
中的<plugin name="cordova-plugin-whitelist" version="1" />
应设置为1.0.0
。<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
,我也不确定它是如何在Android上运行的。在Content-Security-Policy上找到更多信息。没有任何代码,我无法提出任何建议,但我在Stack Overflow上发现这个question似乎可能会对你有帮助。
似乎是一个网址问题。
答案 1 :(得分:0)
对于iOS,请确保您遵循iOS 9 +的ATS应用传输政策
如果要访问外部URL,可以将属性设置为任意加载true。
示例PhoneGap: modify config.xml to add properties to Info.plist ion iOS
答案 2 :(得分:0)
它在iOS模拟器中有效吗?
答案 3 :(得分:0)
问题出在证书上。
为了解决这个问题,我发布了分发(而不是开发)证书,两个条款(Ad Hoc for local testing and AppStore),之后,它发挥了作用。