Add a debug option to force re-register FCM

This commit is contained in:
Grishka 2024-09-20 11:46:31 +03:00
parent 26f7a75628
commit c6130e4d29
2 changed files with 11 additions and 0 deletions

View File

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

View File

@ -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<Void>{
setTitle("Debug settings");
ListItem<Void> 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<Void>{
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;