Skip to content

Commit a3a60c4

Browse files
App crash when denying permissions #33
1 parent 0b1e8ad commit a3a60c4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [1.2.3](https://github.com/EddyVerbruggen/nativescript-calendar/tree/1.2.3) (2018-01-09)
4+
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-calendar/compare/1.2.2...1.2.3)
5+
6+
**Fixed bugs:**
7+
8+
- App crash when denying permissions [\#33](https://github.com/EddyVerbruggen/nativescript-calendar/issues/33)
9+
10+
311
## [1.2.2](https://github.com/EddyVerbruggen/nativescript-calendar/tree/1.2.2) (2017-05-05)
412
[Full Changelog](https://github.com/EddyVerbruggen/nativescript-calendar/compare/1.2.1...1.2.2)
513

calendar.android.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var utils = require("utils/utils");
33
var Color = require("color").Color;
44
var Calendar = require("./calendar-common");
55

6+
var PERMISSION_REQUEST_CODE = 2222;
7+
68
Calendar._fields = {
79
EVENT_ID: android.provider.CalendarContract.Instances.EVENT_ID,
810
CALENDAR: {
@@ -22,6 +24,9 @@ Calendar._fields = {
2224

2325
(function () {
2426
application.android.on(application.AndroidApplication.activityRequestPermissionsEvent, function (args) {
27+
if (args.requestCode !== PERMISSION_REQUEST_CODE) {
28+
return;
29+
}
2530
for (var i = 0; i < args.permissions.length; i++) {
2631
if (args.grantResults[i] === android.content.pm.PackageManager.PERMISSION_DENIED) {
2732
Calendar._reject("Please allow access to the Calendar and try again.");
@@ -65,7 +70,7 @@ Calendar._requestPermission = function(permissions, onPermissionGranted, reject)
6570
android.support.v4.app.ActivityCompat.requestPermissions(
6671
application.android.foregroundActivity,
6772
permissions,
68-
123 // irrelevant since we simply invoke onPermissionGranted
73+
PERMISSION_REQUEST_CODE
6974
);
7075
};
7176

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-calendar",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Interact with the native calendar. Add, Update, Read, you name it.",
55
"main": "calendar",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)