A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix android 13 notifications
ammarahm-ed16f8172d4263
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.tsindex 3e562e46f..861f620e6 100644--- a/apps/mobile/app/services/notifications.ts+++ b/apps/mobile/app/services/notifications.ts@@ -32,6 +32,7 @@ import { DDS } from "./device-detection";import { eSendEvent } from "./event-manager";import SettingsService from "./settings";import { editorState } from "../screens/editor/tiptap/utils";+import DeviceInfo from "react-native-device-info";const NOTIFICATION_TAG = "notesnook";const CHANNEL_ID = "com.streetwriters.notesnook";@@ -149,7 +150,20 @@ function remove(tag: string, id: string) {});}-function pinQuickNote(launch: boolean) {+async function hasPermissions() {+ if (DeviceInfo.getApiLevelSync() < 33) return true;+ //@ts-ignore+ if (!(await PushNotification.areNotificationsEnabled())) {+ //@ts-ignore+ const result = await PushNotification.askForPermission();+ if (result) return true;+ return true;+ }+ return true;+}++async function pinQuickNote(launch: boolean) {+ if (!(await hasPermissions())) return;get().then((items) => {const notif = items.filter((i) => i.tag === "notesnook_note_input");if (notif && launch) {@@ -173,7 +187,7 @@ async function unpinQuickNote() {SettingsService.set({ notifNotes: false });}-function present({+async function present({title,message,subtitle,@@ -196,6 +210,7 @@ function present({reply_button_text?: string;id?: number;}) {+ if (!(await hasPermissions())) return;PushNotification.localNotification({id: id,channelId: CHANNEL_ID,diff --git a/apps/mobile/native/android/app/src/main/AndroidManifest.xml b/apps/mobile/native/android/app/src/main/AndroidManifest.xmlindex 4fcd9ea36..4abc52abb 100644--- a/apps/mobile/native/android/app/src/main/AndroidManifest.xml+++ b/apps/mobile/native/android/app/src/main/AndroidManifest.xml@@ -15,6 +15,8 @@<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>+<applicationandroid:name=".MainApplication"diff --git a/apps/mobile/native/android/build.gradle b/apps/mobile/native/android/build.gradleindex 074d8fa94..dd33f374c 100644--- a/apps/mobile/native/android/build.gradle+++ b/apps/mobile/native/android/build.gradle@@ -3,10 +3,10 @@ import org.apache.tools.ant.taskdefs.condition.Osbuildscript {ext {- buildToolsVersion = "31.0.0"+ buildToolsVersion = "33.0.0"minSdkVersion = 21- compileSdkVersion = 31- targetSdkVersion = 31+ compileSdkVersion = 33+ targetSdkVersion = 33ext.kotlinVersion = '1.6.10'androidXAnnotation = "1.1.0"androidXCoreVersion = "1.7.0"diff --git a/apps/mobile/native/package.json b/apps/mobile/native/package.jsonindex 34aad1fb0..44fa4326b 100644--- a/apps/mobile/native/package.json+++ b/apps/mobile/native/package.json@@ -40,7 +40,7 @@"react-native-mmkv-storage": "^0.8.0","react-native-orientation": "https://github.com/yamill/react-native-orientation.git","react-native-privacy-snapshot": "https://github.com/standardnotes/react-native-privacy-snapshot.git",- "react-native-push-notification": "^8.1.1",+ "react-native-push-notification": "github:ammarahm-ed/react-native-push-notification","react-native-reanimated": "2.9.1","react-native-safe-area-context": "^4.3.1","react-native-scoped-storage": "^1.9.3",diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.jsonindex 8ebdc024c..d4cf57bd9 100644--- a/apps/mobile/package-lock.json+++ b/apps/mobile/package-lock.json@@ -92,7 +92,7 @@"react-native-mmkv-storage": "^0.8.0","react-native-orientation": "https://github.com/yamill/react-native-orientation.git","react-native-privacy-snapshot": "https://github.com/standardnotes/react-native-privacy-snapshot.git",- "react-native-push-notification": "^8.1.1",+ "react-native-push-notification": "github:ammarahm-ed/react-native-push-notification","react-native-reanimated": "2.9.1","react-native-safe-area-context": "^4.3.1","react-native-scoped-storage": "^1.9.3",@@ -18329,8 +18329,8 @@},"node_modules/react-native-push-notification": {"version": "8.1.1",- "resolved": "https://registry.npmjs.org/react-native-push-notification/-/react-native-push-notification-8.1.1.tgz",- "integrity": "sha512-XpBtG/w+a6WXTxu6l1dNYyTiHnbgnvjoc3KxPTxYkaIABRmvuJZkFxqruyGvfCw7ELAlZEAJO+dthdTabCe1XA==",+ "resolved": "git+ssh://[email protected]/ammarahm-ed/react-native-push-notification.git#2e5face06c33ef2faf5917d3a641cd65bbdaa837",+ "license": "MIT","peerDependencies": {"@react-native-community/push-notification-ios": "^1.10.1","react-native": ">=0.33"@@ -24246,7 +24246,7 @@"react-native-mmkv-storage": "^0.8.0","react-native-orientation": "https://github.com/yamill/react-native-orientation.git","react-native-privacy-snapshot": "https://github.com/standardnotes/react-native-privacy-snapshot.git",- "react-native-push-notification": "^8.1.1",+ "react-native-push-notification": "github:ammarahm-ed/react-native-push-notification","react-native-reanimated": "2.9.1","react-native-safe-area-context": "^4.3.1","react-native-scoped-storage": "^1.9.3",@@ -34969,9 +34969,8 @@}},"react-native-push-notification": {- "version": "8.1.1",- "resolved": "https://registry.npmjs.org/react-native-push-notification/-/react-native-push-notification-8.1.1.tgz",- "integrity": "sha512-XpBtG/w+a6WXTxu6l1dNYyTiHnbgnvjoc3KxPTxYkaIABRmvuJZkFxqruyGvfCw7ELAlZEAJO+dthdTabCe1XA=="+ "version": "git+ssh://[email protected]/ammarahm-ed/react-native-push-notification.git#2e5face06c33ef2faf5917d3a641cd65bbdaa837",+ "from": "react-native-push-notification@github:ammarahm-ed/react-native-push-notification"},"react-native-qrcode-svg": {"version": "6.1.2",diff --git a/apps/mobile/patches/react-native-push-notification+8.1.1.patch b/apps/mobile/patches/react-native-push-notification+8.1.1.patchdeleted file mode 100644index 29e9eb345..000000000--- a/apps/mobile/patches/react-native-push-notification+8.1.1.patch+++ /dev/null@@ -1,440 +0,0 @@-diff --git a/node_modules/react-native-push-notification/android/build.gradle b/node_modules/react-native-push-notification/android/build.gradle-index d6019f6..1f7e5d1 100644---- a/node_modules/react-native-push-notification/android/build.gradle-+++ b/node_modules/react-native-push-notification/android/build.gradle-@@ -60,5 +60,4 @@ dependencies {- implementation "$appCompatLibName:$supportLibVersion"- implementation 'com.facebook.react:react-native:+'- implementation 'me.leolin:ShortcutBadger:1.1.22@aar'-- implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '21.1.0')}"- }-diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java-index d162680..56c5a76 100644---- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java-+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java-@@ -2,14 +2,11 @@ package com.dieam.reactnativepushnotification.modules;-- import android.app.Activity;- import android.app.Application;--import android.app.NotificationManager;--import android.content.BroadcastReceiver;--import android.content.Context;- import android.content.Intent;--import android.content.IntentFilter;-+import android.os.Build;- import android.os.Bundle;--import androidx.annotation.NonNull;- import androidx.annotation.Nullable;-+import androidx.annotation.RequiresApi;- import androidx.core.app.NotificationManagerCompat;-- import com.dieam.reactnativepushnotification.helpers.ApplicationBadgeHelper;-@@ -26,7 +23,6 @@ import com.facebook.react.bridge.WritableArray;- import com.facebook.react.bridge.ReadableMap;- import com.facebook.react.bridge.WritableMap;---import java.io.IOException;- import java.security.SecureRandom;- import java.util.ArrayList;- import java.util.HashMap;-@@ -34,9 +30,6 @@ import java.util.Map;-- import android.util.Log;---import com.google.android.gms.tasks.OnCompleteListener;--import com.google.android.gms.tasks.Task;--import com.google.firebase.messaging.FirebaseMessaging;-- public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {- public static final String LOG_TAG = "RNPushNotification";// all logging should use this tag-@@ -137,30 +130,6 @@ public class RNPushNotification extends ReactContextBaseJavaModule implements Ac- public void requestPermissions() {- final RNPushNotificationJsDelivery fMjsDelivery = mJsDelivery;--- FirebaseMessaging.getInstance().getToken()-- .addOnCompleteListener(new OnCompleteListener<String>() {-- @Override-- public void onComplete(@NonNull Task<String> task) {-- if (!task.isSuccessful()) {-- Log.e(LOG_TAG, "exception", task.getException());-- return;-- }---- WritableMap params = Arguments.createMap();-- params.putString("deviceToken", task.getResult());-- fMjsDelivery.sendEvent("remoteNotificationsRegistered", params);-- }-- });-- }---- @ReactMethod-- public void subscribeToTopic(String topic) {-- FirebaseMessaging.getInstance().subscribeToTopic(topic);-- }---- @ReactMethod-- public void unsubscribeFromTopic(String topic) {-- FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);- }-- @ReactMethod-@@ -280,7 +249,6 @@ public class RNPushNotification extends ReactContextBaseJavaModule implements Ac- * Unregister for all remote notifications received- */- public void abandonPermissions() {-- FirebaseMessaging.getInstance().deleteToken();- Log.i(LOG_TAG, "InstanceID deleted");- }--diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java-index 248ff08..ff198d5 100644---- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java-+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java-@@ -56,11 +56,12 @@ public class RNPushNotificationHelper {- private Context context;- private RNPushNotificationConfig config;- private final SharedPreferences scheduledNotificationsPersistence;---+ private int FLAG_MUTABLE = 1<<25;- public RNPushNotificationHelper(Application context) {- this.context = context;- this.config = new RNPushNotificationConfig(context);- this.scheduledNotificationsPersistence = context.getSharedPreferences(RNPushNotificationHelper.PREFERENCES_KEY, Context.MODE_PRIVATE);-+- }-- public Class getMainActivityClass() {-@@ -455,6 +456,7 @@ public class RNPushNotificationHelper {-- int notificationID = Integer.parseInt(notificationIdString);--+- PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent,- Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT);--@@ -533,7 +535,18 @@ public class RNPushNotificationHelper {- intent.putExtra("message_id", messageId);- }--- int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;-+ int flags = PendingIntent.FLAG_UPDATE_CURRENT;-+-+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {-+ if(action.equals("ReplyInput") ) {-+ if (Build.VERSION.SDK_INT == 31) {-+ flags = PendingIntent.FLAG_UPDATE_CURRENT | FLAG_MUTABLE;-+ }-+ }-+ else {-+ flags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;-+ }-+ }-- PendingIntent pendingActionIntent = PendingIntent.getBroadcast(context, notificationID, actionIntent, flags);--diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java-index ca78c03..9ee3650 100644---- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java-+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationListenerService.java-@@ -1,79 +1,5 @@- package com.dieam.reactnativepushnotification.modules;---import com.google.firebase.messaging.FirebaseMessagingService;--import com.google.firebase.messaging.RemoteMessage;-+public class RNPushNotificationListenerService {---import android.os.Handler;--import android.os.Looper;--import android.util.Log;----import com.facebook.react.ReactApplication;--import com.facebook.react.ReactInstanceManager;--import com.facebook.react.bridge.Arguments;--import com.facebook.react.bridge.ReactApplicationContext;--import com.facebook.react.bridge.ReactContext;--import com.facebook.react.bridge.WritableMap;----import static com.dieam.reactnativepushnotification.modules.RNPushNotification.LOG_TAG;----public class RNPushNotificationListenerService extends FirebaseMessagingService {---- private RNReceivedMessageHandler mMessageReceivedHandler;-- private FirebaseMessagingService mFirebaseServiceDelegate;---- public RNPushNotificationListenerService() {-- super();-- this.mMessageReceivedHandler = new RNReceivedMessageHandler(this);-- }---- public RNPushNotificationListenerService(FirebaseMessagingService delegate) {-- super();-- this.mFirebaseServiceDelegate = delegate;-- this.mMessageReceivedHandler = new RNReceivedMessageHandler(delegate);-- }---- @Override-- public void onNewToken(String token) {-- final String deviceToken = token;-- final FirebaseMessagingService serviceRef = (this.mFirebaseServiceDelegate == null) ? this : this.mFirebaseServiceDelegate;-- Log.d(LOG_TAG, "Refreshed token: " + deviceToken);---- Handler handler = new Handler(Looper.getMainLooper());-- handler.post(new Runnable() {-- public void run() {-- // Construct and load our normal React JS code bundle-- final ReactInstanceManager mReactInstanceManager = ((ReactApplication)serviceRef.getApplication()).getReactNativeHost().getReactInstanceManager();-- ReactContext context = mReactInstanceManager.getCurrentReactContext();-- // If it's constructed, send a notification-- if (context != null) {-- handleNewToken((ReactApplicationContext) context, deviceToken);-- } else {-- // Otherwise wait for construction, then send the notification-- mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {-- public void onReactContextInitialized(ReactContext context) {-- handleNewToken((ReactApplicationContext) context, deviceToken);-- mReactInstanceManager.removeReactInstanceEventListener(this);-- }-- });-- if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {-- // Construct it in the background-- mReactInstanceManager.createReactContextInBackground();-- }-- }-- }-- });-- }---- private void handleNewToken(ReactApplicationContext context, String token) {-- RNPushNotificationJsDelivery jsDelivery = new RNPushNotificationJsDelivery(context);---- WritableMap params = Arguments.createMap();-- params.putString("deviceToken", token);-- jsDelivery.sendEvent("remoteNotificationsRegistered", params);-- }---- @Override-- public void onMessageReceived(RemoteMessage message) {-- mMessageReceivedHandler.handleReceivedMessage(message);-- }- }-diff --git a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java-index 721ca40..b7bff2f 100644---- a/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java-+++ b/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNReceivedMessageHandler.java-@@ -1,215 +1,6 @@- package com.dieam.reactnativepushnotification.modules;---import com.google.firebase.messaging.FirebaseMessagingService;--import com.google.firebase.messaging.RemoteMessage;----import android.app.ActivityManager;--import android.app.ActivityManager.RunningAppProcessInfo;--import android.app.Application;--import android.os.Bundle;--import android.os.Handler;--import android.os.Looper;--import android.content.Context;--import android.util.Log;--import android.net.Uri;--import androidx.annotation.NonNull;--import androidx.core.app.NotificationCompat;----import com.dieam.reactnativepushnotification.helpers.ApplicationBadgeHelper;--import com.facebook.react.ReactApplication;--import com.facebook.react.ReactInstanceManager;--import com.facebook.react.bridge.ReactApplicationContext;--import com.facebook.react.bridge.ReactContext;----import org.json.JSONObject;----import java.util.Map;--import java.util.List;--import java.security.SecureRandom;----import static android.content.Context.ACTIVITY_SERVICE;--import static com.dieam.reactnativepushnotification.modules.RNPushNotification.LOG_TAG;--- public class RNReceivedMessageHandler {-- private FirebaseMessagingService mFirebaseMessagingService;---- public RNReceivedMessageHandler(@NonNull FirebaseMessagingService service) {-- this.mFirebaseMessagingService = service;-- }---- public void handleReceivedMessage(RemoteMessage message) {-- String from = message.getFrom();-- RemoteMessage.Notification remoteNotification = message.getNotification();-- final Bundle bundle = new Bundle();-- // Putting it from remoteNotification first so it can be overriden if message-- // data has it-- if (remoteNotification != null) {-- // ^ It's null when message is from GCM-- RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());---- String title = getLocalizedString(remoteNotification.getTitle(), remoteNotification.getTitleLocalizationKey(), remoteNotification.getTitleLocalizationArgs());-- String body = getLocalizedString(remoteNotification.getBody(), remoteNotification.getBodyLocalizationKey(), remoteNotification.getBodyLocalizationArgs());---- bundle.putString("title", title);-- bundle.putString("message", body);-- bundle.putString("sound", remoteNotification.getSound());-- bundle.putString("color", remoteNotification.getColor());-- bundle.putString("tag", remoteNotification.getTag());---- if(remoteNotification.getIcon() != null) {-- bundle.putString("smallIcon", remoteNotification.getIcon());-- } else {-- bundle.putString("smallIcon", "ic_notification");-- }---- if(remoteNotification.getChannelId() != null) {-- bundle.putString("channelId", remoteNotification.getChannelId());-- }-- else {-- bundle.putString("channelId", config.getNotificationDefaultChannelId());-- }---- Integer visibilty = remoteNotification.getVisibility();-- String visibilityString = "private";---- if (visibilty != null) {-- switch (visibilty) {-- case NotificationCompat.VISIBILITY_PUBLIC:-- visibilityString = "public";-- break;-- case NotificationCompat.VISIBILITY_SECRET:-- visibilityString = "secret";-- break;-- }-- }---- bundle.putString("visibility", visibilityString);---- Integer priority = remoteNotification.getNotificationPriority();-- String priorityString = "high";---- if (priority != null) {-- switch (priority) {-- case NotificationCompat.PRIORITY_MAX:-- priorityString = "max";-- break;-- case NotificationCompat.PRIORITY_LOW:-- priorityString = "low";-- break;-- case NotificationCompat.PRIORITY_MIN:-- priorityString = "min";-- break;-- case NotificationCompat.PRIORITY_DEFAULT:-- priorityString = "default";-- break;-- }-- }---- bundle.putString("priority", priorityString);---- Uri uri = remoteNotification.getImageUrl();---- if(uri != null) {-- String imageUrl = uri.toString();--- bundle.putString("bigPictureUrl", imageUrl);-- bundle.putString("largeIconUrl", imageUrl);-- }-- }---- Bundle dataBundle = new Bundle();-- Map<String, String> notificationData = message.getData();---- for(Map.Entry<String, String> entry : notificationData.entrySet()) {-- dataBundle.putString(entry.getKey(), entry.getValue());-- }---- bundle.putParcelable("data", dataBundle);---- Log.v(LOG_TAG, "onMessageReceived: " + bundle);---- // We need to run this on the main thread, as the React code assumes that is true.-- // Namely, DevServerHelper constructs a Handler() without a Looper, which triggers:-- // "Can't create handler inside thread that has not called Looper.prepare()"-- Handler handler = new Handler(Looper.getMainLooper());-- handler.post(new Runnable() {-- public void run() {-- // Construct and load our normal React JS code bundle-- final ReactInstanceManager mReactInstanceManager = ((ReactApplication) mFirebaseMessagingService.getApplication()).getReactNativeHost().getReactInstanceManager();-- ReactContext context = mReactInstanceManager.getCurrentReactContext();-- // If it's constructed, send a notificationre-- if (context != null) {-- handleRemotePushNotification((ReactApplicationContext) context, bundle);-- } else {-- // Otherwise wait for construction, then send the notification-- mReactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {-- public void onReactContextInitialized(ReactContext context) {-- handleRemotePushNotification((ReactApplicationContext) context, bundle);-- mReactInstanceManager.removeReactInstanceEventListener(this);-- }-- });-- if (!mReactInstanceManager.hasStartedCreatingInitialContext()) {-- // Construct it in the background-- mReactInstanceManager.createReactContextInBackground();-- }-- }-- }-- });-- }---- private void handleRemotePushNotification(ReactApplicationContext context, Bundle bundle) {---- // If notification ID is not provided by the user for push notification, generate one at random-- if (bundle.getString("id") == null) {-- SecureRandom randomNumberGenerator = new SecureRandom();-- bundle.putString("id", String.valueOf(randomNumberGenerator.nextInt()));-- }---- Application applicationContext = (Application) context.getApplicationContext();---- RNPushNotificationConfig config = new RNPushNotificationConfig(mFirebaseMessagingService.getApplication());-- RNPushNotificationHelper pushNotificationHelper = new RNPushNotificationHelper(applicationContext);---- boolean isForeground = pushNotificationHelper.isApplicationInForeground();---- RNPushNotificationJsDelivery jsDelivery = new RNPushNotificationJsDelivery(context);-- bundle.putBoolean("foreground", isForeground);-- bundle.putBoolean("userInteraction", false);-- jsDelivery.notifyNotification(bundle);---- // If contentAvailable is set to true, then send out a remote fetch event-- if (bundle.getString("contentAvailable", "false").equalsIgnoreCase("true")) {-- jsDelivery.notifyRemoteFetch(bundle);-- }---- if (config.getNotificationForeground() || !isForeground) {-- Log.v(LOG_TAG, "sendNotification: " + bundle);---- pushNotificationHelper.sendToNotificationCentre(bundle);-- }-- }---- private String getLocalizedString(String text, String locKey, String[] locArgs) {-- if(text != null) {-- return text;-- }---- Context context = mFirebaseMessagingService.getApplicationContext();-- String packageName = context.getPackageName();---- String result = null;---- if (locKey != null) {-- int id = context.getResources().getIdentifier(locKey, "string", packageName);-- if (id != 0) {-- if (locArgs != null) {-- result = context.getResources().getString(id, (Object[]) locArgs);-- } else {-- result = context.getResources().getString(id);-- }-- }-- }---- return result;-- }- }-+