mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[notifications] Fix some android issues with local notifications
This commit is contained in:
@@ -30,6 +30,16 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
|
||||
<receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
|
||||
<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"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
|
||||
@@ -45,16 +45,19 @@ const init = async () => {
|
||||
notification
|
||||
.setTitle('Test title')
|
||||
.setBody('Test body')
|
||||
.setNotificationId('displayed')
|
||||
.android.setChannelId('test')
|
||||
.android.setClickAction('action')
|
||||
.android.setPriority(RNfirebase.notifications.Android.Priority.Max);
|
||||
const date = new Date();
|
||||
date.setMinutes(date.getMinutes() + 1);
|
||||
setTimeout(() => {
|
||||
RNfirebase.notifications().displayNotification(notification);
|
||||
notification.setNotificationId('scheduled');
|
||||
RNfirebase.notifications().scheduleNotification(notification, {
|
||||
fireDate: date.getTime(),
|
||||
});
|
||||
}, 5);
|
||||
RNfirebase.notifications().scheduleNotification(notification, {
|
||||
fireDate: date.getTime(),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('messaging init error:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user