diff --git a/android/app/src/play/java/chat/rocket/reactnative/Ejson.java b/android/app/src/play/java/chat/rocket/reactnative/Ejson.java index 0ce46634..e44c6b72 100644 --- a/android/app/src/play/java/chat/rocket/reactnative/Ejson.java +++ b/android/app/src/play/java/chat/rocket/reactnative/Ejson.java @@ -41,6 +41,10 @@ public class Ejson { public Ejson() { ReactApplicationContext reactApplicationContext = CustomPushNotification.reactApplicationContext; + if (reactApplicationContext == null) { + return; + } + // Start MMKV container MMKV.initialize(reactApplicationContext); SecureKeystore secureKeystore = new SecureKeystore(reactApplicationContext); diff --git a/android/app/src/play/java/chat/rocket/reactnative/LoadNotification.java b/android/app/src/play/java/chat/rocket/reactnative/LoadNotification.java index 20d1313d..6b6ad6be 100644 --- a/android/app/src/play/java/chat/rocket/reactnative/LoadNotification.java +++ b/android/app/src/play/java/chat/rocket/reactnative/LoadNotification.java @@ -57,9 +57,16 @@ public class LoadNotification { final OkHttpClient client = new OkHttpClient(); HttpUrl.Builder url = HttpUrl.parse(ejson.serverURL().concat("/api/v1/push.get")).newBuilder(); + final String userId = ejson.userId(); + final String userToken = ejson.token(); + + if (userId == null || userToken == null) { + return; + } + Request request = new Request.Builder() - .header("x-user-id", ejson.userId()) - .header("x-auth-token", ejson.token()) + .header("x-user-id", userId) + .header("x-auth-token", userToken) .url(url.addQueryParameter("id", ejson.messageId).build()) .build();