第一次在這裏問一個問題,所以很抱歉如果我錯過任何東西。離子權限不會改變(android)
我想開發一個跨平臺的應用程序,目前正在android上測試,但是,我無法獲得任何權限,不包括默認的「完全網絡訪問」權限。我正在嘗試獲取CALL_PHONE權限,但一直在嘗試測試其他人。
我試過同時使用Cordova-plugins-android-permissions和Cordova-plugins-diagnostic,但是,它們似乎沒有在其頁面上調用示例函數(也是alert(cordova.plugins。權限)返回未定義)。
我已經嘗試了SDK版本22和24中的應用程序,看看我是否可以獲得工作棉花糖前的權限但沒有任何效果(這包括顯然不需要它自己的請求的振動許可)。
我在附上我的index.html(我的主頁),config.xml和androidmanifest.xml下面。
在此先感謝。
的Index.html:
<!DOCTYPE html>
<html>
<head>
<script src="../jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="../jquery-ui.css">
<script src="jquery-3.1.1.min.js"></script>
<link rel="stylesheet" href="jquery-ui.css">
<link rel="stylesheet" href="lone.css">
<script src="js/MainCtrl.js"></script>
<script>
$ionicPlatform.ready(function() {
window.plugin.notification.local.promptForPermission();
});
window.onload = function(){
window.PhoneCaller.call("//Editing for privacy", onSuccess, onError);
var permissions = cordova.plugins.permissions;
permissions.hasPermission(permissions.CAMERA, checkPermissionCallback, null);
function checkPermissionCallback(status) {
if(!status.hasPermission) {
var errorCallback = function() {
alert('Camera permission is not turned on');
}
permissions.requestPermission(
permissions.CAMERA,
function(status) {
if(!status.hasPermission) errorCallback();
},
errorCallback);
}
}
//window.location.href ="test.java";
var check = 1;
var url=window.location.href
url = url.substring(url.indexOf(".html")+5,url.length);
if(url.length>0){
try{
localStorage.removeItem("name");
localStorage.removeItem("no");
localStorage.removeItem("email");
localStorage.removeItem("timer");
}
catch(err){
}
var bigname = url.substring(url.indexOf("name=")+5,url.indexOf("&"));
localStorage.setItem("name",bigname);
url=url.substring(url.indexOf(bigname)+bigname.length+1,url.length);
var bigno = url.substring(url.indexOf("noin=")+5,url.indexOf("&"));
localStorage.setItem("no",bigno);
url=url.substring(url.indexOf(bigno)+bigno.length+1,url.length);
var bigemail = url.substring(url.indexOf("email=")+6,url.indexOf("&"));
localStorage.setItem("email",bigemail);
url=url.substring(url.indexOf(bigemail)+bigemail.length+1,url.length);
var bigtimer = url.substring(url.indexOf("timer=")+6,url.indexOf("&"));
localStorage.setItem("timer",bigtimer);
}
}
function test(){
if(check == 1){
document.getElementById("call").click;
$('#call')[0].click();
undo();
}
}
function undo(){
check = 0;
wait(500);
check = 1;
}
function move(){
try{
window.location.href = "task.html?name=" + localStorage.getItem('name') + "&noin=" + localStorage.getItem('no') + "&email=" + localStorage.getItem('email') + "&timer=" + localStorage.getItem('timer') +"&";
}
catch(err){
}
}
function onSuccess(result){
alert("Success:"+result);
}
function onError(result) {
alert("Error:"+result);
}
</script>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link rel="manifest" href="manifest.json">
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
</head>
<body id="bod" ng-app="starter" ng-controller="MainCtrl">
<div id="mainbutt" onclick="move()">
</div>
<div id="settings" onclick="location.href='settings.html'">
</div>
<a id="call" href="tel://Edited for privacy" ng-href="tel://Edited For Privacy" onclick="test()"><span id="callspan">CALL</span></a>
</body>
</html>
config.xml文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.loneworker957777" version="0.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>LoneWorker</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="[email protected]" href="http://example.com.com/">
Your Name Here
</author>
<content src="index.html"/>
<access origin="*"/>
<allow-intent href="tel:*" launch-external="yes"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="SplashScreenDelay" value="2000"/>
<preference name="FadeSplashScreenDuration" value="2000"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="CDVConnection"/>
</feature>
<platform name="ios">
<icon src="resources\ios\icon\icon.png" width="57" height="57"/>
<icon src="resources\ios\icon\[email protected]" width="114" height="114"/>
<icon src="resources\ios\icon\icon-40.png" width="40" height="40"/>
<icon src="resources\ios\icon\[email protected]" width="80" height="80"/>
<icon src="resources\ios\icon\[email protected]" width="120" height="120"/>
<icon src="resources\ios\icon\icon-50.png" width="50" height="50"/>
<icon src="resources\ios\icon\[email protected]" width="100" height="100"/>
<icon src="resources\ios\icon\icon-60.png" width="60" height="60"/>
<icon src="resources\ios\icon\[email protected]" width="120" height="120"/>
<icon src="resources\ios\icon\[email protected]" width="180" height="180"/>
<icon src="resources\ios\icon\icon-72.png" width="72" height="72"/>
<icon src="resources\ios\icon\[email protected]" width="144" height="144"/>
<icon src="resources\ios\icon\icon-76.png" width="76" height="76"/>
<icon src="resources\ios\icon\[email protected]" width="152" height="152"/>
<icon src="resources\ios\icon\[email protected]" width="167" height="167"/>
<icon src="resources\ios\icon\icon-small.png" width="29" height="29"/>
<icon src="resources\ios\icon\[email protected]" width="58" height="58"/>
<icon src="resources\ios\icon\[email protected]" width="87" height="87"/>
<splash src="resources\ios\splash\[email protected]~iphone.png" width="640" height="1136"/>
<splash src="resources\ios\splash\Default-667h.png" width="750" height="1334"/>
<splash src="resources\ios\splash\Default-736h.png" width="1242" height="2208"/>
<splash src="resources\ios\splash\Default-Landscape-736h.png" width="2208" height="1242"/>
<splash src="resources\ios\splash\[email protected]~ipad.png" width="2048" height="1536"/>
<splash src="resources\ios\splash\Default-Landscape~ipad.png" width="1024" height="768"/>
<splash src="resources\ios\splash\[email protected]~ipad.png" width="1536" height="2048"/>
<splash src="resources\ios\splash\Default-Portrait~ipad.png" width="768" height="1024"/>
<splash src="resources\ios\splash\[email protected]~iphone.png" width="640" height="960"/>
<splash src="resources\ios\splash\Default~iphone.png" width="320" height="480"/>
</platform>
<platform name="android">
<config-file target="AndroidManifest.xml">
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CALL_PRIVILEGED"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission_group.PHONE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:name="android.software.sip" android:required="true"/>
<uses-feature android:name="android.software.sip.voip" android:required="true"/>
<uses-feature android:name="android.software.sip" android:required="true"/>
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
</config-file>
<icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
<icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
<icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
<icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
<splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
<splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
<splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
<splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
<splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
<splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
<splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
<splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
<splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
<splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
<splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
<splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
</platform>
<platform name="wp8">
<icon src="resources\wp8\icon\ApplicationIcon.png" width="99" height="99"/>
<icon src="resources\wp8\icon\Background.png" width="159" height="159"/>
<splash src="resources\wp8\splash\SplashScreenImage.png" width="768" height="1280"/>
</platform>
<icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
</widget>
的AndroidManifest.xml:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:versionCode="3" android:versionName="0.0.3" package="com.ionicframework.loneworker957777" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:name="android.software.sip" android:required="false" />
<uses-feature android:name="android.software.sip.voip" android:required="false" />
<uses-feature android:name="android.software.sip" android:required="false" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application android:label="@string/app_name">
<activity android:label="@string/activity_name" android:launchMode="singleTop" android:name="index">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission_group.PHONE" />
</manifest>
編輯:應該澄清 - 的電話通話結束我M正在尋找我的應用程序,使用Android的CALL_PHONE權限直接調用規定的號碼,而不是打開手機ķ。只要打開電話簿,測試功能就能正確點擊工作,但我希望它立即開始通話。
編輯2:添加plugin.xml和permissions.java,因爲它們涉及到android.permissions插件。
的plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-android-permissions"
version="0.10.0">
<name>Permissions</name>
<description>Android permissions support library.</description>
<author>Jason Yang</author>
<engines>
<engine name="cordova" version=">=5.0.0"/>
</engines>
<!-- android -->
<platform name="android">
<js-module src="www/permissions.js" name="Permissions">
<clobbers target="cordova.plugins.permissions" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Permissions">
<param name="android-package" value="com.android.plugins.Permissions" />
</feature>
</config-file>
<source-file src="src/android/com/android/plugins/Permissions.java" target-dir="src/com/android/plugins"/>
</platform>
</plugin>
permissions.java:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
評論是從作者,而不是從我順便說一句。
你確定window.PhoneCaller.call接受一個字符串作爲第一個參數嗎?你有鏈接到這個文件? Object.call通常需要這個,一個對象或null – chriskelly
window.PhoneCaller.call來自https://github.com/codebakery/cordova-plugin-phonecaller - 另一個插件,我嘗試作爲解決,但沒有權限,我不能直接撥打電話,測試()會通過打出帶有附加號碼的電話簿正常工作。不過,我需要它可以直接使用CALL_PHONE權限進行調用(應該在原始對話中澄清此問題,我將添加一個編輯)。 –
假設你安裝了插件(我無法在你的config.xml中看到它,所以可能沒有--save標誌),我通常會期望plugin.xml中的插件的權限。就像'<使用權限android:name =「android.permission.CALL_PHONE」/>'。但它不在那裏,這個插件版本爲0.0.2。也許找到另一個插件,或者分發這個插件,讓你自己調整plugin.xml。 – JanP