3838import com .google .firebase .iid .InstanceIdResult ;
3939import com .google .firebase .messaging .FirebaseMessaging ;
4040
41- public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {
41+ public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener , Application . ActivityLifecycleCallbacks {
4242 public static final String LOG_TAG = "RNPushNotification" ;// all logging should use this tag
4343
4444 private RNPushNotificationHelper mRNPushNotificationHelper ;
@@ -51,6 +51,7 @@ public RNPushNotification(ReactApplicationContext reactContext) {
5151 reactContext .addActivityEventListener (this );
5252
5353 Application applicationContext = (Application ) reactContext .getApplicationContext ();
54+ applicationContext .registerActivityLifecycleCallbacks (this );
5455
5556 // The @ReactNative methods use this
5657 mRNPushNotificationHelper = new RNPushNotificationHelper (applicationContext );
@@ -81,6 +82,8 @@ private Bundle getBundleFromIntent(Intent intent) {
8182 }
8283 return bundle ;
8384 }
85+
86+ @ Override
8487 public void onNewIntent (Intent intent ) {
8588 Bundle bundle = this .getBundleFromIntent (intent );
8689 if (bundle != null ) {
@@ -277,4 +280,45 @@ public void run() {
277280 }
278281 }).start ();
279282 }
283+
284+ @ Override
285+ public void onActivityCreated (Activity activity , Bundle bundle ) {
286+
287+ }
288+
289+ @ Override
290+ public void onActivityStarted (Activity activity ) {
291+ Intent intent = activity .getIntent ();
292+ Bundle bundle = this .getBundleFromIntent (intent );
293+ if (bundle != null ) {
294+ bundle .putBoolean ("foreground" , false );
295+ intent .putExtra ("notification" , bundle );
296+ mJsDelivery .notifyNotification (bundle );
297+ }
298+ }
299+
300+ @ Override
301+ public void onActivityResumed (Activity activity ) {
302+
303+ }
304+
305+ @ Override
306+ public void onActivityPaused (Activity activity ) {
307+
308+ }
309+
310+ @ Override
311+ public void onActivityStopped (Activity activity ) {
312+
313+ }
314+
315+ @ Override
316+ public void onActivitySaveInstanceState (Activity activity , Bundle bundle ) {
317+
318+ }
319+
320+ @ Override
321+ public void onActivityDestroyed (Activity activity ) {
322+
323+ }
280324}
0 commit comments