question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not requesting for permissions popup for android 6 and above.

See original GitHub issue

Hello, I am trying to integrate the code in ionic 1. I am not getting the popup of requesting permission on android 6 and above both emulator and android phones.

Please find my code below

app.js

$ionicPlatform.on('deviceready', function(){
var permissions = cordova.plugins.permissions;
     permissions.hasPermission(permissions.WRITE_EXTERNAL_STORAGE, function(status) {
            if (status.hasPermission) {
              alert('you already have permission');
            } else {
              alert('need to request permission');
              permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE, successCallback, errorCallback);

              function errorCallback() {
                alert('permission not turned on');
              }

              function successCallback(status) {
                if (status.hasPermission) {
                  alert('user accepted, here you can start your own plugin');
                }
              }
            }
          });
});

AndroidManifest.xml

 <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
 <uses-permission android:name="android.permission.WAKE_LOCK"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Ionic Info

Ionic:

   ionic (Ionic CLI) : 4.1.0 (/home/user/lib/node_modules/ionic)
   Ionic Framework   : ionic1 1.3.3
   @ionic/v1-toolkit : 1.0.6

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 6.4.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, (and 32 other plugins)

System:

   Android SDK Tools : 26.1.1
   NodeJS            : v6.9.0 (/home/user/.nvm/versions/node/v6.9.0/bin/node)
   npm               : 6.6.0
   OS                : Linux 4.15

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:18

github_iconTop GitHub Comments

1reaction
Gioele-Bencivengacommented, Jun 20, 2022

Actually just “solved” my permission issue on android by going into the AndroidManifest.xml file and manually adding the line <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />.

Now the pemission gets asked via the popup if not present.

1reaction
NivedhaL20commented, Feb 12, 2019

Even I am facing the same issue. I have tried upgrading the cordova-android version to 7.1.0. But still the permission popup is not popping out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request app permissions - Android Developers
Overview · Standalone apps · Authentication · Request permissions · Detect location · Playing audio on wearables · Appear in Recents and App...
Read more >
Change app permissions on your Android phone
On your phone, open the settings app. · Tap Privacy And then Permission manager. · Tap a permission type. If you allowed or...
Read more >
Android 6.0 not request contact permission - Ionic Forum
Hi all I have some trouble with ionic and Android M. I need to access to the account saved on the device(like facebook...
Read more >
Android M permission dialog not showing - Stack Overflow
I experienced the same issue but later I realized I forgot to add the permission to the manifest file. After adding the uses-permission...
Read more >
How to Request Permissions in Android Application?
Check for permissions: Beginning with Android 6.0 (API level 23), the user has the right to revoke permissions from any app at any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found