3131
3232public class RNReceivedMessageHandler {
3333 private FirebaseMessagingService mFirebaseMessagingService ;
34- private RNPushNotificationConfig config ;
3534
3635 public RNReceivedMessageHandler (@ NonNull FirebaseMessagingService service ) {
3736 this .mFirebaseMessagingService = service ;
38- this .config = new RNPushNotificationConfig (service .getApplication ());
3937 }
4038
4139 public void handleReceivedMessage (RemoteMessage message ) {
@@ -46,17 +44,19 @@ public void handleReceivedMessage(RemoteMessage message) {
4644 // data has it
4745 if (remoteNotification != null ) {
4846 // ^ It's null when message is from GCM
47+ RNPushNotificationConfig config = new RNPushNotificationConfig (mFirebaseMessagingService .getApplication ());
48+
4949 bundle .putString ("title" , remoteNotification .getTitle ());
5050 bundle .putString ("message" , remoteNotification .getBody ());
5151 bundle .putString ("sound" , remoteNotification .getSound ());
5252 bundle .putString ("color" , remoteNotification .getColor ());
5353 bundle .putString ("tag" , remoteNotification .getTag ());
54-
54+
5555 if (remoteNotification .getChannelId () != null ) {
5656 bundle .putString ("channelId" , remoteNotification .getChannelId ());
5757 }
5858 else {
59- bundle .putString ("channelId" , this . config .getNotificationDefaultChannelId ());
59+ bundle .putString ("channelId" , config .getNotificationDefaultChannelId ());
6060 }
6161
6262 Integer visibilty = remoteNotification .getVisibility ();
@@ -157,6 +157,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
157157
158158 Application applicationContext = (Application ) context .getApplicationContext ();
159159
160+ RNPushNotificationConfig config = new RNPushNotificationConfig (mFirebaseMessagingService .getApplication ());
160161 RNPushNotificationHelper pushNotificationHelper = new RNPushNotificationHelper (applicationContext );
161162
162163 boolean isForeground = pushNotificationHelper .isApplicationInForeground ();
@@ -171,7 +172,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
171172 jsDelivery .notifyRemoteFetch (bundle );
172173 }
173174
174- if (this . config .getNotificationForeground () || !isForeground ) {
175+ if (config .getNotificationForeground () || !isForeground ) {
175176 Log .v (LOG_TAG , "sendNotification: " + bundle );
176177
177178 pushNotificationHelper .sendToNotificationCentre (bundle );
0 commit comments