如何在Ionic 3中使用cordova-plugin-android-permissions? [英] How to use cordova-plugin-android-permissions in Ionic 3?

查看:1067
本文介绍了如何在Ionic 3中使用cordova-plugin-android-permissions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了几个cordova插件,如相机和图像拾取器,它们在所有设备上运行良好......但问题来自于从手机获取这些插件的权限。 Android 6以下版本在安装时要求这些权限,但Android 6及更高版本仅在用户第一次使用该应用程序内的插件时(即在运行时)请求这些权限。

I am using a couple of cordova plugins like camera and Image Pickers in my App and they work great on all the Devices… but the problem comes for getting the Permission to these plugins from the phone. Below Android 6 Versions asks for these permissions while installing but Android 6 and above ask for these permissions only when for the first time when the user uses that plugin inside the application(i.e during the Runtime).

我发现这个 Ionic本机插件可以处理这些权限Android的所有版本但完全没有得到如何使用它或在我的代码中使用它,所以如果任何人有任何视频或了解它,那么请在这里提到它。

I found this Ionic native plugin to handle these permissions in all versions of Android But exactly not getting how to use it or where to use it in my code, So If anyone has any Videos or know anything about it then please mention it here.

谢谢,

推荐答案

我想出了如何使用这个原生插件。这就是我的尝试。

I figured it out how to use this native plugin. this is what I tried.


安装插件,如这个离子文档

然后在我的应用程序中。 component.ts文件

then in my app.component.ts file

import { AndroidPermissions } from '@ionic-native/android-permissions';

constructor(platform: Platform, androidPermissions: AndroidPermissions) {
    platform.ready().then(() => {

         androidPermissions.requestPermissions(
           [
             androidPermissions.PERMISSION.CAMERA, 
             androidPermissions.PERMISSION.CALL_PHONE, 
             androidPermissions.PERMISSION.GET_ACCOUNTS, 
             androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE, 
             androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE
           ]
         );

    }) 
}

我希望这会对某人有所帮助。谢谢。

I hope this will help someone. Thanks.

这篇关于如何在Ionic 3中使用cordova-plugin-android-permissions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆