|
|
@ -66,14 +66,16 @@ public class CustomReceiver extends MessagingReceiver {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onNewEndpoint(@Nullable Context context, @NotNull String endpoint, @NotNull String slug) {
|
|
|
|
public void onNewEndpoint(@Nullable Context context, @NotNull String endpoint, @NotNull String slug) {
|
|
|
|
if (context != null) {
|
|
|
|
if (context != null) {
|
|
|
|
|
|
|
|
synchronized(this) {
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
String storedEnpoint = sharedpreferences.getString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, null);
|
|
|
|
String storedEnpoint = sharedpreferences.getString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, null);
|
|
|
|
if(storedEnpoint == null || !storedEnpoint.equalsIgnoreCase(endpoint)) {
|
|
|
|
if(storedEnpoint == null || !storedEnpoint.equals(endpoint)) {
|
|
|
|
PushNotifications
|
|
|
|
PushNotifications
|
|
|
|
.registerPushNotifications(context, endpoint, slug);
|
|
|
|
.registerPushNotifications(context, endpoint, slug);
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
|
|
editor.putString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, endpoint);
|
|
|
|
editor.putString(context.getString(R.string.SET_STORED_ENDPOINT)+slug, endpoint);
|
|
|
|
editor.apply();
|
|
|
|
editor.commit();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|