[notifications] Fix some android issues with local notifications

This commit is contained in:
Chris Bianca
2018-03-07 18:29:53 +00:00
parent aa367e7be8
commit 57ffa9bd3e
7 changed files with 119 additions and 57 deletions

View File

@@ -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"

View File

@@ -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);
}