16
AndroidでMarshmallowのユーザーは、アプリケーションの実行中ではなく、実行時のPermissonsのチェックと付与方法を許可するのではなく、アプリケーションの実行中に許可を与えますか?実行時に権限を要求するIonic
AndroidでMarshmallowのユーザーは、アプリケーションの実行中ではなく、実行時のPermissonsのチェックと付与方法を許可するのではなく、アプリケーションの実行中に許可を与えますか?実行時に権限を要求するIonic
あなたはチェックして、Androidのランタイム許可を要求するためにcordova-diagnostic-pluginを使用することができます。
cordova.plugins.diagnostic.getPermissionAuthorizationStatus(function(status){
switch(status){
case cordova.plugins.diagnostic.runtimePermissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
}, cordova.plugins.diagnostic.runtimePermission.CAMERA);
要求許可:
は許可チェック
cordova.plugins.diagnostic.requestRuntimePermission(function(status){
switch(status){
case cordova.plugins.diagnostic.runtimePermissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case cordova.plugins.diagnostic.runtimePermissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
}, cordova.plugins.diagnostic.runtimePermission.CAMERA);
こんにちはデイブ - ちょうどここに、成功コールバックを状態パラメータをとります。ファイルを保存するなど、成功したときに何か他のアクションを起こしたいのですが?あなたが保存する前にパーミッションが確認されるまで待つことを望むので、それを行う自然な場所はコールバック関数内にあるようですが、それはオプションではありません。ステータスをグローバルパラメータ(yuk)に格納する必要がありますか?より良いアプローチがありますか? –
'cordova.plugins.diagnostic.runtimePermission.CAMERA'の代わりにJson配列' ['CAMERA'] 'それ以外は失敗します。 – YumYumYum
???確かに 'cordova.plugins.diagnostic.runtimePermission.CAMERA === cordova.plugins.diagnostic.runtimePermission ['CAMERA']' – DaveAlden