Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
taymer committed May 19, 2020
1 parent 6887be9 commit 821cad2
Showing 1 changed file with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import com.google.firebase.iid.InstanceIdResult;
import com.google.firebase.messaging.FirebaseMessaging;

public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {
public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener , Application.ActivityLifecycleCallbacks{
public static final String LOG_TAG = "RNPushNotification";// all logging should use this tag

private RNPushNotificationHelper mRNPushNotificationHelper;
Expand All @@ -51,6 +51,7 @@ public RNPushNotification(ReactApplicationContext reactContext) {
reactContext.addActivityEventListener(this);

Application applicationContext = (Application) reactContext.getApplicationContext();
applicationContext.registerActivityLifecycleCallbacks(this);

// The @ReactNative methods use this
mRNPushNotificationHelper = new RNPushNotificationHelper(applicationContext);
Expand Down Expand Up @@ -81,6 +82,8 @@ private Bundle getBundleFromIntent(Intent intent) {
}
return bundle;
}

@Override
public void onNewIntent(Intent intent) {
Bundle bundle = this.getBundleFromIntent(intent);
if (bundle != null) {
Expand Down Expand Up @@ -277,4 +280,45 @@ public void run() {
}
}).start();
}

@Override
public void onActivityCreated(Activity activity, Bundle bundle) {

}

@Override
public void onActivityStarted(Activity activity) {
Intent intent = activity.getIntent();
Bundle bundle = this.getBundleFromIntent(intent);
if (bundle != null) {
bundle.putBoolean("foreground", false);
intent.putExtra("notification", bundle);
mJsDelivery.notifyNotification(bundle);
}
}

@Override
public void onActivityResumed(Activity activity) {

}

@Override
public void onActivityPaused(Activity activity) {

}

@Override
public void onActivityStopped(Activity activity) {

}

@Override
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {

}

@Override
public void onActivityDestroyed(Activity activity) {

}
}

0 comments on commit 821cad2

Please sign in to comment.