diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java b/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java index 6a31d984..a903f70d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/PushSubscriptionManager.java @@ -93,6 +93,10 @@ public class PushSubscriptionManager{ this.accountID=accountID; } + public static void resetLocalPreferences(){ + getPrefs().edit().clear().apply(); + } + public static void tryRegisterFCM(){ deviceToken=getPrefs().getString("deviceToken", null); int tokenVersion=getPrefs().getInt("version", 0); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java index 43697d58..c267988c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDebugFragment.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.widget.Toast; import org.joinmastodon.android.GlobalUserPreferences; +import org.joinmastodon.android.api.PushSubscriptionManager; import org.joinmastodon.android.api.session.AccountActivationInfo; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; @@ -29,6 +30,7 @@ public class SettingsDebugFragment extends BaseSettingsFragment{ setTitle("Debug settings"); ListItem selfUpdateItem, resetUpdateItem; onDataLoaded(List.of( + new ListItem<>("Re-register for FCM", null, this::onUpdatePushRegistrationClick), new ListItem<>("Test email confirmation flow", null, this::onTestEmailConfirmClick), selfUpdateItem=new ListItem<>("Force self-update", null, this::onForceSelfUpdateClick), resetUpdateItem=new ListItem<>("Reset self-updater", null, this::onResetUpdaterClick), @@ -52,6 +54,11 @@ public class SettingsDebugFragment extends BaseSettingsFragment{ getPrefs().edit().putBoolean("donationsStaging", donationsStagingItem.checked).apply(); } + private void onUpdatePushRegistrationClick(ListItem item){ + PushSubscriptionManager.resetLocalPreferences(); + PushSubscriptionManager.tryRegisterFCM(); + } + private void onTestEmailConfirmClick(ListItem item){ AccountSession sess=AccountSessionManager.getInstance().getAccount(accountID); sess.activated=false;