diff --git a/CHANGELOG.md b/CHANGELOG.md index 15a598a..5af8470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/calendar.android.js b/calendar.android.js index df0787a..ef9f9a9 100755 --- a/calendar.android.js +++ b/calendar.android.js @@ -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: { @@ -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."); @@ -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 ); }; diff --git a/package.json b/package.json index d1e22ad..724d7d5 100644 --- a/package.json +++ b/package.json @@ -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",