From 56d27a1e2beeb4f334d8521b998ca945190dcdfe Mon Sep 17 00:00:00 2001 From: Vlad Shcherban Date: Fri, 20 Aug 2021 16:08:11 +0300 Subject: [PATCH] Fixing crash in ignoreFCM for Android --- .../android/plugin.notifications.v2.jar | Bin 20326 -> 20556 bytes .../v2/CoronaFirebaseMessagingService.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/2020.3569/android/plugin.notifications.v2.jar b/plugins/2020.3569/android/plugin.notifications.v2.jar index 72d99f5f9243c86782930ac4dfcfbd6b11d960d9..7a663f0c26eba0f211833e242bead40f50d1d16b 100644 GIT binary patch delta 1599 zcmV-F2Eh5|o&n6D0k8xGe^yy@(^eGzE_NbYR!T5n_5g(vlMqB%0wk0sF?QqPnACPd zNtaZSZyXU>awXZ&ec!idenDS&0j37ZOsCKN8~qoZ>2j{DK!QzLm`rr9kIp^kJKtG! zfB*ZJUjZD$k20P{TE<>vqV#w{!laBavJt!};k*n9=?HRSof7Z!e=%IZwD|dwcobw5 zQIhboj9$zLD;I^mS7cnmtk}IO;WZfvye{Jn%*F5~v>4{0i$_@km$4HIGAdY%z=+_o zge3_k!}{q$I+HG>^QrV)CYwt$#B-OmhNhaDRZ)wcV_20@hDh;zc6u(8nqufaV_1fF zmLZfpIKvQ5*=0_4e{zP!^Y!XHcS_p4$%P$T*UTBsF~sjc81@zom*G^dX4Wf)rCPRU zEEu}x8MfuBjiYMHc5F+_7!IG;Tt3BJS0lYjkvk1T=Y%9`R4m)!J`_SQ%MhzMe1SXM z(m9#lm(#4WV;f~vw=Iubo?2Yg9A2J&phQ+e+;JE-uL!lYf9Tj(1W0<@Q}i@_X-cd4 zsEKuk4Yt(+!wX#JMuV3bjwExsT~#Z#T`{@35MWlT%b?W)ui9P^1RoV_^*Ad<3`37) zfkC#dJik)1m$*gnlkKSzP9&#pc}A7Y@A1uRmaA(-hhR1!xX{udi?K2n%myZV9bPe9 z&+!vd(%dD6f8ll;yg|IWYJNrX3J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67-(b%unwwS{#Awm+h7H?5J3u&|Jqhrnbk5wd?=~d0y1aKLR zr>8sgKPcU9*7-cLn&DyE$y)T?Ib`F|%)YfQu z9d%4L*6{3crLHWFj-bgVnclKrH~((rP5z>6V%;{z$w3yf*OsrCln9 z>i~83%7B=J0(l~L7y?+5NgzMXou~xVlFdPT5A8$}Xav2xFFgVQJ!BV&nE?`={?TsOp#Y4NvW)f_iSPFxIM<1S diff --git a/src/android/plugin/src/main/java/plugin/notifications/v2/CoronaFirebaseMessagingService.java b/src/android/plugin/src/main/java/plugin/notifications/v2/CoronaFirebaseMessagingService.java index 67c91cf..6321254 100644 --- a/src/android/plugin/src/main/java/plugin/notifications/v2/CoronaFirebaseMessagingService.java +++ b/src/android/plugin/src/main/java/plugin/notifications/v2/CoronaFirebaseMessagingService.java @@ -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"; @@ -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()) {