Skip to content

Commit

Permalink
App crash when denying permissions #33
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 9, 2018
1 parent 0b1e8ad commit a3a60c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [1.2.3](https://github.com/EddyVerbruggen/nativescript-calendar/tree/1.2.3) (2018-01-09)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-calendar/compare/1.2.2...1.2.3)

**Fixed bugs:**

- App crash when denying permissions [\#33](https://github.com/EddyVerbruggen/nativescript-calendar/issues/33)


## [1.2.2](https://github.com/EddyVerbruggen/nativescript-calendar/tree/1.2.2) (2017-05-05)
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-calendar/compare/1.2.1...1.2.2)

Expand Down
7 changes: 6 additions & 1 deletion calendar.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var utils = require("utils/utils");
var Color = require("color").Color;
var Calendar = require("./calendar-common");

var PERMISSION_REQUEST_CODE = 2222;

Calendar._fields = {
EVENT_ID: android.provider.CalendarContract.Instances.EVENT_ID,
CALENDAR: {
Expand All @@ -22,6 +24,9 @@ Calendar._fields = {

(function () {
application.android.on(application.AndroidApplication.activityRequestPermissionsEvent, function (args) {
if (args.requestCode !== PERMISSION_REQUEST_CODE) {
return;
}
for (var i = 0; i < args.permissions.length; i++) {
if (args.grantResults[i] === android.content.pm.PackageManager.PERMISSION_DENIED) {
Calendar._reject("Please allow access to the Calendar and try again.");
Expand Down Expand Up @@ -65,7 +70,7 @@ Calendar._requestPermission = function(permissions, onPermissionGranted, reject)
android.support.v4.app.ActivityCompat.requestPermissions(
application.android.foregroundActivity,
permissions,
123 // irrelevant since we simply invoke onPermissionGranted
PERMISSION_REQUEST_CODE
);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-calendar",
"version": "1.2.2",
"version": "1.2.3",
"description": "Interact with the native calendar. Add, Update, Read, you name it.",
"main": "calendar",
"typings": "index.d.ts",
Expand Down

0 comments on commit a3a60c4

Please sign in to comment.