38
38
import com .google .firebase .iid .InstanceIdResult ;
39
39
import com .google .firebase .messaging .FirebaseMessaging ;
40
40
41
- public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {
41
+ public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener , Application . ActivityLifecycleCallbacks {
42
42
public static final String LOG_TAG = "RNPushNotification" ;// all logging should use this tag
43
43
44
44
private RNPushNotificationHelper mRNPushNotificationHelper ;
@@ -51,6 +51,7 @@ public RNPushNotification(ReactApplicationContext reactContext) {
51
51
reactContext .addActivityEventListener (this );
52
52
53
53
Application applicationContext = (Application ) reactContext .getApplicationContext ();
54
+ applicationContext .registerActivityLifecycleCallbacks (this );
54
55
55
56
// The @ReactNative methods use this
56
57
mRNPushNotificationHelper = new RNPushNotificationHelper (applicationContext );
@@ -81,6 +82,8 @@ private Bundle getBundleFromIntent(Intent intent) {
81
82
}
82
83
return bundle ;
83
84
}
85
+
86
+ @ Override
84
87
public void onNewIntent (Intent intent ) {
85
88
Bundle bundle = this .getBundleFromIntent (intent );
86
89
if (bundle != null ) {
@@ -277,4 +280,45 @@ public void run() {
277
280
}
278
281
}).start ();
279
282
}
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
+ }
280
324
}
0 commit comments