prefer localized fields to the regular ones

This commit is contained in:
Vojtech Novak 2018-07-24 17:09:44 +02:00 committed by GitHub
parent 28dfbdf253
commit deaf794271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -316,28 +316,30 @@ public class RNFirebaseNotifications extends ReactContextBaseJavaModule implemen
}
private @Nullable String getNotificationTitle(RemoteMessage.Notification notification) {
String title, titleLocKey;
if ((title = notification.getTitle()) != null) {
return title;
} else if ((titleLocKey = notification.getTitleLocalizationKey()) != null) {
String title = notification.getTitle();
String titleLocKey = notification.getTitleLocalizationKey();
if (titleLocKey != null) {
String[] titleLocArgs = notification.getTitleLocalizationArgs();
Context ctx = getReactApplicationContext();
int resId = getResId(ctx, titleLocKey);
return ctx.getResources().getString(resId, (Object[]) titleLocArgs);
} else if (title != null) {
return title;
} else {
return null;
}
}
private @Nullable String getNotificationBody(RemoteMessage.Notification notification) {
String body = notification.getBody(), bodyLocKey = notification.getBodyLocalizationKey();
if (body != null) {
return body;
} else if (bodyLocKey != null) {
String body = notification.getBody();
String bodyLocKey = notification.getBodyLocalizationKey();
if (bodyLocKey != null) {
String[] bodyLocArgs = notification.getBodyLocalizationArgs();
Context ctx = getReactApplicationContext();
int resId = getResId(ctx, bodyLocKey);
return ctx.getResources().getString(resId, (Object[]) bodyLocArgs);
} else if (body != null) {
return body;
} else {
return null;
}