Skip to content

Commit

Permalink
fix #189 - fix permissions verification android
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Alvez committed Sep 9, 2016
1 parent 90d7d42 commit 01f6f54
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ ionic.Platform.ready(function() {

// Now launch the app
try {
if (window.ionic.Platform.isAndroid()) {
var permissions = window.cordova.plugins.permissions;
permissions.hasPermission(permissions.WRITE_EXTERNAL_STORAGE, function(status) {
checkPermissionCallback(status, permissions);
}, null);
} else {
angular.bootstrap(document, ['geotrekMobileApp']);
}
}
catch(e) {
console.log(e);
Expand All @@ -51,6 +58,27 @@ ionic.Platform.ready(function() {

});

function checkPermissionCallback(status, permissions) {
if(!status.hasPermission) {
var errorCallback = function() {
console.warn('Storge permission is not granted');
}

permissions.requestPermission(
permissions.WRITE_EXTERNAL_STORAGE,
function(status) {
if(!status.hasPermission) {
errorCallback();
} else {
angular.bootstrap(document, ['geotrekMobileApp']);
}
},
errorCallback);
} else {
angular.bootstrap(document, ['geotrekMobileApp']);
}
}

function handleOpenURL(url) {
}

Expand Down

0 comments on commit 01f6f54

Please sign in to comment.