Skip to content

Commit 6442ef2

Browse files
committed
fix(local-notifications): support API31+
1 parent 6c9f360 commit 6442ef2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/local-notifications/index.android.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application, Utils } from '@nativescript/core';
1+
import { Application, Device, Utils } from '@nativescript/core';
22
import { LocalNotificationsApi, LocalNotificationsCommon, ReceivedNotification, ScheduleInterval, ScheduleOptions } from './common';
33

44
declare const com, global: any;
@@ -55,7 +55,11 @@ export class LocalNotificationsImpl extends LocalNotificationsCommon implements
5555
private static cancelById(id: number): void {
5656
const context = Utils.android.getApplicationContext();
5757
const notificationIntent = new android.content.Intent(context, com.telerik.localnotifications.NotificationAlarmReceiver.class).setAction('' + id);
58-
const pendingIntent = android.app.PendingIntent.getBroadcast(context, 0, notificationIntent, 0);
58+
let flags = 0;
59+
if (parseInt(Device.sdkVersion) >= 31) {
60+
flags |= 33554432;
61+
}
62+
const pendingIntent = android.app.PendingIntent.getBroadcast(context, 0, notificationIntent, flags);
5963
const alarmManager = context.getSystemService(android.content.Context.ALARM_SERVICE);
6064
alarmManager.cancel(pendingIntent);
6165
const notificationManager = context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);

packages/local-notifications/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/local-notifications",
3-
"version": "5.0.3",
3+
"version": "5.0.4",
44
"description": "The Local Notifications plugin allows your app to show notifications when the app is not running.",
55
"main": "index",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)