Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

ionic3 - How to use cordova-plugin-android-permissions in Ionic 3?

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).

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.

Thanks,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Installed the Plugin as mentioned in this ionic doc

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...