31
31
32
32
public class RNReceivedMessageHandler {
33
33
private FirebaseMessagingService mFirebaseMessagingService ;
34
- private RNPushNotificationConfig config ;
35
34
36
35
public RNReceivedMessageHandler (@ NonNull FirebaseMessagingService service ) {
37
36
this .mFirebaseMessagingService = service ;
38
- this .config = new RNPushNotificationConfig (service .getApplication ());
39
37
}
40
38
41
39
public void handleReceivedMessage (RemoteMessage message ) {
@@ -46,17 +44,19 @@ public void handleReceivedMessage(RemoteMessage message) {
46
44
// data has it
47
45
if (remoteNotification != null ) {
48
46
// ^ It's null when message is from GCM
47
+ RNPushNotificationConfig config = new RNPushNotificationConfig (mFirebaseMessagingService .getApplication ());
48
+
49
49
bundle .putString ("title" , remoteNotification .getTitle ());
50
50
bundle .putString ("message" , remoteNotification .getBody ());
51
51
bundle .putString ("sound" , remoteNotification .getSound ());
52
52
bundle .putString ("color" , remoteNotification .getColor ());
53
53
bundle .putString ("tag" , remoteNotification .getTag ());
54
-
54
+
55
55
if (remoteNotification .getChannelId () != null ) {
56
56
bundle .putString ("channelId" , remoteNotification .getChannelId ());
57
57
}
58
58
else {
59
- bundle .putString ("channelId" , this . config .getNotificationDefaultChannelId ());
59
+ bundle .putString ("channelId" , config .getNotificationDefaultChannelId ());
60
60
}
61
61
62
62
Integer visibilty = remoteNotification .getVisibility ();
@@ -157,6 +157,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
157
157
158
158
Application applicationContext = (Application ) context .getApplicationContext ();
159
159
160
+ RNPushNotificationConfig config = new RNPushNotificationConfig (mFirebaseMessagingService .getApplication ());
160
161
RNPushNotificationHelper pushNotificationHelper = new RNPushNotificationHelper (applicationContext );
161
162
162
163
boolean isForeground = pushNotificationHelper .isApplicationInForeground ();
@@ -171,7 +172,7 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
171
172
jsDelivery .notifyRemoteFetch (bundle );
172
173
}
173
174
174
- if (this . config .getNotificationForeground () || !isForeground ) {
175
+ if (config .getNotificationForeground () || !isForeground ) {
175
176
Log .v (LOG_TAG , "sendNotification: " + bundle );
176
177
177
178
pushNotificationHelper .sendToNotificationCentre (bundle );
0 commit comments