Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
448 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...