mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-06-18 07:19:15 +08:00
Add missing Android messaging file for local notifications; Document local notification setup
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package io.invertase.firebase.messaging;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Set alarms for scheduled notification after system reboot.
|
||||
*/
|
||||
public class RNFirebaseSystemBootEventReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i("FCMSystemBootReceiver", "Received reboot event");
|
||||
RNFirebaseLocalMessagingHelper helper = new RNFirebaseLocalMessagingHelper((Application) context.getApplicationContext());
|
||||
ArrayList<Bundle> bundles = helper.getScheduledLocalNotifications();
|
||||
for(Bundle bundle: bundles){
|
||||
helper.sendNotificationScheduled(bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,3 +80,16 @@ Add messaging service:
|
||||
</intent-filter>
|
||||
</service>
|
||||
```
|
||||
|
||||
If you would like to schedule local notifications then you also need to add the following:
|
||||
```
|
||||
<receiver android:name="io.invertase.firebase.messaging.RNFirebaseLocalMessagingPublisher"/>
|
||||
<receiver android:enabled="true" android:exported="true"android:name="io.invertase.firebase.messaging.RNFirebaseSystemBootEventReceiver">
|
||||
<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>
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user