Fix issue #997 - Store endpoint and create it only if it changes

This commit is contained in:
Thomas 2023-12-14 10:01:55 +01:00
parent eb0ecd7583
commit 0982e1bb38
1 changed files with 10 additions and 8 deletions

View File

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