I’m using Ionic v8 and Capacitor LocalNotification v6.
I’m compiling it for android.
I’ve the following permissions set in my AndroidManifest.xml file
<uses-permission
android:name="android.permission.SCHEDULE_EXACT_ALARM"
android:maxSdkVersion="32"
/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
The push notification doesn’t work in production. The app is on play store.
I’ve this:
const scheduleNotification = async () => {
await store.create();
const notification = await store.get("notification");
const value ="1";
const options: ScheduleOptions = {
notifications: [
{
id: 0,
title: "Don't forget your rewards!",
body: "Time to earn",
largeBody: "Time to earn some free XAH",
summaryText: "Earn XAH",
largeIcon: "res://drawable/icon_bel48",
smallIcon: "res://drawable/icon_bel48",
sound: "notify.wav",
schedule: { every: "hour", count: 8, allowWhileIdle: true },
},
],
};
const status: PermissionStatus =
await LocalNotifications.checkPermissions();
if (status.display === "granted" && notification !== value) {
await LocalNotifications.schedule(options);
await store.set("notification", value);
} else {
await LocalNotifications.requestPermissions();
await store.set("notification", "revoke");
}
};