@@ -46,8 +46,10 @@ public void handleReceivedMessage(RemoteMessage message) {
4646 // ^ It's null when message is from GCM
4747 RNPushNotificationConfig config = new RNPushNotificationConfig (mFirebaseMessagingService .getApplication ());
4848
49- bundle .putString ("title" , remoteNotification .getTitle ());
50- bundle .putString ("message" , remoteNotification .getBody ());
49+ bundle .putString ("title" , getLocalizedString (remoteNotification .getTitleLocalizationKey (),
50+ remoteNotification .getTitleLocalizationArgs (), remoteNotification .getTitle ()));
51+ bundle .putString ("message" , getLocalizedString (remoteNotification .getBodyLocalizationKey (),
52+ remoteNotification .getBodyLocalizationArgs (), remoteNotification .getBody ()));
5153 bundle .putString ("sound" , remoteNotification .getSound ());
5254 bundle .putString ("color" , remoteNotification .getColor ());
5355 bundle .putString ("tag" , remoteNotification .getTag ());
@@ -178,4 +180,20 @@ private void handleRemotePushNotification(ReactApplicationContext context, Bundl
178180 pushNotificationHelper .sendToNotificationCentre (bundle );
179181 }
180182 }
183+
184+ private String getLocalizedString (String locKey , String [] locArgs , String defaultText ) {
185+ String packageName = getPackageName ();
186+ String result = defaultText ;
187+ if (locKey != null ) {
188+ int id = getResources ().getIdentifier (locKey , "string" , packageName );
189+ if (id != 0 ) {
190+ if (locArgs != null ) {
191+ result = res .getString (id , (Object []) locArgs );
192+ } else {
193+ result = res .getString (id );
194+ }
195+ }
196+ }
197+ return result ;
198+ }
181199}
0 commit comments