Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onReceived() throws InvalidNotificationException {
Ejson receivedEjson = new Gson().fromJson(received.getString("ejson", "{}"), Ejson.class);

if (receivedEjson.notificationType != null && receivedEjson.notificationType.equals("message-id-only")) {
notificationLoad(receivedEjson.serverURL(), receivedEjson.messageId, new Callback() {
notificationLoad(receivedEjson, new Callback() {
@Override
public void call(@Nullable Bundle bundle) {
if (bundle != null) {
Expand Down Expand Up @@ -340,7 +340,7 @@ private void notificationDismiss(Notification.Builder notification, int notifica
notification.setDeleteIntent(dismissPendingIntent);
}

private void notificationLoad(String server, String messageId, Callback callback) {
LoadNotification.load(reactApplicationContext, server, messageId, callback);
private void notificationLoad(Ejson ejson, Callback callback) {
LoadNotification.load(reactApplicationContext, ejson, callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.os.Bundle;
import android.content.Context;
import android.content.SharedPreferences;

import okhttp3.Call;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -54,19 +53,15 @@ public class LoadNotification {
private static int RETRY_COUNT = 0;
private static int[] TIMEOUT = new int[]{ 0, 1, 3, 5, 10 };
private static String TOKEN_KEY = "reactnativemeteor_usertoken-";
private static SharedPreferences sharedPreferences = RNUserDefaultsModule.getPreferences(CustomPushNotification.reactApplicationContext);

public static void load(ReactApplicationContext reactApplicationContext, final String host, final String msgId, Callback callback) {
public static void load(ReactApplicationContext reactApplicationContext, final Ejson ejson, Callback callback) {
final OkHttpClient client = new OkHttpClient();
HttpUrl.Builder url = HttpUrl.parse(host.concat("/api/v1/push.get")).newBuilder();

String userId = sharedPreferences.getString(TOKEN_KEY.concat(host), "");
String token = sharedPreferences.getString(TOKEN_KEY.concat(userId), "");
HttpUrl.Builder url = HttpUrl.parse(ejson.serverURL().concat("/api/v1/push.get")).newBuilder();

Request request = new Request.Builder()
.header("x-user-id", userId)
.header("x-auth-token", token)
.url(url.addQueryParameter("id", msgId).build())
.header("x-user-id", ejson.userId())
.header("x-auth-token", ejson.token())
.url(url.addQueryParameter("id", ejson.messageId).build())
.build();

runRequest(client, request, callback);
Expand Down