[FIX] App crashing when notification is received/replied (Android) (#2602)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
632e32f872
commit
417f4b1010
|
@ -41,6 +41,10 @@ public class Ejson {
|
||||||
public Ejson() {
|
public Ejson() {
|
||||||
ReactApplicationContext reactApplicationContext = CustomPushNotification.reactApplicationContext;
|
ReactApplicationContext reactApplicationContext = CustomPushNotification.reactApplicationContext;
|
||||||
|
|
||||||
|
if (reactApplicationContext == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Start MMKV container
|
// Start MMKV container
|
||||||
MMKV.initialize(reactApplicationContext);
|
MMKV.initialize(reactApplicationContext);
|
||||||
SecureKeystore secureKeystore = new SecureKeystore(reactApplicationContext);
|
SecureKeystore secureKeystore = new SecureKeystore(reactApplicationContext);
|
||||||
|
|
|
@ -57,9 +57,16 @@ public class LoadNotification {
|
||||||
final OkHttpClient client = new OkHttpClient();
|
final OkHttpClient client = new OkHttpClient();
|
||||||
HttpUrl.Builder url = HttpUrl.parse(ejson.serverURL().concat("/api/v1/push.get")).newBuilder();
|
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()
|
Request request = new Request.Builder()
|
||||||
.header("x-user-id", ejson.userId())
|
.header("x-user-id", userId)
|
||||||
.header("x-auth-token", ejson.token())
|
.header("x-auth-token", userToken)
|
||||||
.url(url.addQueryParameter("id", ejson.messageId).build())
|
.url(url.addQueryParameter("id", ejson.messageId).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue