2
0
mirror of synced 2025-02-02 09:34:45 +00:00

Add missing Android messaging file for local notifications; Document local notification setup

This commit is contained in:
Chris Bianca 2017-03-27 13:48:50 +01:00
parent e25dd05576
commit 10656ce698
2 changed files with 40 additions and 0 deletions

View File

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

View File

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