Local Notifications not working in android
See original GitHub issueI have been trying the Scheduled local notifications but not a single notification is being triggered. I am not able to find exactly where I am doing mistake.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.notes">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/BootTheme">
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" android:exported="false"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" android:exported="false"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground"
android:value="false"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_color"
android:resource="@android:color/white"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
import PushNotification, {Importance} from ‘react-native-push-notification’; import {CONSTANTS} from ‘…/…/constants’;
export default class NotificationService {
static configure() {}
static createChannel() {
PushNotification.channelExists(
CONSTANTS.NOTIFICATION_CHANNEL_ID,
exists => {
if (exists) {
console.log(
createChannel ${CONSTANTS.NOTIFICATION_CHANNEL_ID} already exists
,
);
} else {
PushNotification.createChannel(
{
channelId: CONSTANTS.NOTIFICATION_CHANNEL_ID,
channelName: ‘Notes channel’,
channelDescription: ‘Notes notification channel’,
playSound: true,
soundName: ‘default’,
importance: Importance.HIGH,
vibrate: true,
},
created => console.log(createChannel returned '${created}'
),
);
}
},
);
}
static getAllScheduledNotifications() {
PushNotification.getScheduledLocalNotifications(notifications => {
console.log(notifications);
});
}
static scheduleNotification({notificationID, title, description, timestamp}) {
PushNotification.localNotificationSchedule({
date: new Date(timestamp),
channelId: CONSTANTS.NOTIFICATION_CHANNEL_ID,
id: notificationID,
vibrate: true,
vibration: 300,
title: title,
message: description,
playSound: true,
soundName: ‘default’,
});
}
static cancelNotification(notificationID) {
PushNotification.cancelLocalNotification(notificationID);
}
}
Is there any thing more which we need to change?
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top GitHub Comments
@roma-hladilka Still no notifications. Also I am not able to receive normal notifications.
Work at first times, but then not. I see that I received push, but it work and show only if app is closed(background). if reinstall package it work again. What’s wrong?