[FIX] App crashing when notification is received/replied (Android) (#2602)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-11-03 14:14:27 -03:00 committed by GitHub
parent 632e32f872
commit 417f4b1010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -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);

View File

@ -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();