Repository: ably/ably-flutter
Issue: Customer reporting issue with NPE on Android push notifications

Details: 
Hi , we also noticed that after the move to official ably plugin, we're getting a surge in the following error for Android:


{code}
Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.error(java.lang.String, java.lang.String, java.lang.Object)' on a null object reference
io.ably.flutter.plugin.push.PushActivationEventHandlers$BroadcastReceiver.returnMethodCallResult (PushActivationEventHandlers.java:86)
io.ably.flutter.plugin.push.PushActivationEventHandlers$BroadcastReceiver.onReceive (PushActivationEventHandlers.java:72)
androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts (LocalBroadcastManager.java:313)
androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage (LocalBroadcastManager.java:121)
android.os.Handler.dispatchMessage (Handler.java:106)
android.os.Looper.loop (Looper.java:226)
android.app.ActivityThread.main (ActivityThread.java:7191)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:499)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:942)
{code}
Seems to be impacting mainly certain manufacturers/models


{code}
62% Xiaomi
21% OPPO
5% Realme
5% realme
3% vivo
2% samsung
1% HUAWEI
<1% INFINIX MOBILITY LIMITED
<1% asus
<1% Sony
<1% Meizu
{code}
TODO: 
Make sure you handle the situation where result is null
Check iOS implementation to see how this case is handled

Changed files:
android/src/main/java/io/ably/flutter/plugin/push/PushActivationEventHandlers.java

diff --git a/android/src/main/java/io/ably/flutter/plugin/push/PushActivationEventHandlers.java b/android/src/main/java/io/ably/flutter/plugin/push/PushActivationEventHandlers.java
index 7fd1a7a4..01a7e7fa 100644
--- a/android/src/main/java/io/ably/flutter/plugin/push/PushActivationEventHandlers.java
+++ b/android/src/main/java/io/ably/flutter/plugin/push/PushActivationEventHandlers.java
@@ -64,13 +64,23 @@ public class PushActivationEventHandlers {
       switch (action) {
         case PUSH_ACTIVATE_ACTION:
           callCallbackOnDartSide(PlatformConstants.PlatformMethod.pushOnActivate, errorInfo);
-          returnMethodCallResult(resultForActivate, errorInfo);
-          resultForActivate = null;
+          if (resultForActivate != null) {
+            Log.d(TAG, "resultForActivate received on PUSH_ACTIVATE_ACTION.");
+            returnMethodCallResult(resultForActivate, errorInfo);
+            resultForActivate = null;
+          } else {
+            Log.e(TAG, "resultForActivate is null on PUSH_ACTIVATE_ACTION.");
+          }
           break;
         case PUSH_DEACTIVATE_ACTION:
           callCallbackOnDartSide(PlatformConstants.PlatformMethod.pushOnDeactivate, errorInfo);
-          returnMethodCallResult(resultForDeactivate, errorInfo);
-          resultForDeactivate = null;
+          if (resultForDeactivate != null) {
+            Log.d(TAG, "resultForDeactivate received on PUSH_DEACTIVATE_ACTION.");
+            returnMethodCallResult(resultForDeactivate, errorInfo);
+            resultForDeactivate = null;
+          } else {
+            Log.e(TAG, "resultForDeactivate is null on PUSH_DEACTIVATE_ACTION.");
+          }
           break;
         case PUSH_UPDATE_FAILED_ACTION:
           callCallbackOnDartSide(PlatformConstants.PlatformMethod.pushOnUpdateFailed, errorInfo);