Skip to content

Commit

Permalink
Fixing crash in ignoreFCM for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Shchvova committed Aug 20, 2021
1 parent 58165ed commit 56d27a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Binary file modified plugins/2020.3569/android/plugin.notifications.v2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// Class definition
// -------------------------------------------------------

public class CoronaFirebaseMessagingService extends FirebaseMessagingService
{
public class CoronaFirebaseMessagingService extends FirebaseMessagingService {
public static String PREFERENCE_FILE = "fcm-notifications";
public static String SKIP_FCM = "skipFCM";

Expand All @@ -31,20 +30,24 @@ public CoronaFirebaseMessagingService() {
}

private boolean ignoreFCM() {
SharedPreferences preferences = CoronaEnvironment.getApplicationContext().getSharedPreferences(PREFERENCE_FILE, Context.MODE_PRIVATE);
return preferences.getBoolean(SKIP_FCM, false);
try {
SharedPreferences preferences = getApplicationContext().getSharedPreferences(PREFERENCE_FILE, Context.MODE_PRIVATE);
return preferences.getBoolean(SKIP_FCM, false);
} catch (Throwable ignore) {
}
return false;
}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(ignoreFCM()) return;;
if (ignoreFCM()) return;
super.onMessageReceived(remoteMessage);
NotificationsV2Helper.processRemoteMessage(remoteMessage, getApplicationContext());
}

@Override
public void onNewToken( String deviceToken ) {
if(ignoreFCM()) return;;
public void onNewToken(String deviceToken) {
if (ignoreFCM()) return;
super.onNewToken(deviceToken);
NotificationRegistrationTask registrationTask = new NotificationRegistrationTask(deviceToken);
for (com.ansca.corona.CoronaRuntime runtime : com.ansca.corona.CoronaRuntimeProvider.getAllCoronaRuntimes()) {
Expand Down

0 comments on commit 56d27a1

Please sign in to comment.