diff --git a/app/src/fdroid/java/com/keylesspalace/tusky/MessagingService.java b/app/src/fdroid/java/com/keylesspalace/tusky/MessagingService.java index ca446945d..eaa1b1b53 100644 --- a/app/src/fdroid/java/com/keylesspalace/tusky/MessagingService.java +++ b/app/src/fdroid/java/com/keylesspalace/tusky/MessagingService.java @@ -134,4 +134,9 @@ public class MessagingService extends IntentService { .putStringSet("current_ids", currentIds) .apply(); } + + public static String getInstanceToken() { + // This is only used for the "google" build flavor, so this version is just a stub method. + return null; + } } diff --git a/app/src/google/java/com/keylesspalace/tusky/MessagingService.java b/app/src/google/java/com/keylesspalace/tusky/MessagingService.java index c32fff093..4a2a55da5 100644 --- a/app/src/google/java/com/keylesspalace/tusky/MessagingService.java +++ b/app/src/google/java/com/keylesspalace/tusky/MessagingService.java @@ -25,6 +25,7 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.text.Spanned; +import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import com.google.gson.Gson; @@ -125,4 +126,8 @@ public class MessagingService extends FirebaseMessagingService { mastodonAPI = retrofit.create(MastodonAPI.class); } + + public static String getInstanceToken() { + return FirebaseInstanceId.getInstance().getToken(); + } } diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 1803cacd1..859b46496 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -204,7 +204,7 @@ public class BaseActivity extends AppCompatActivity { protected void enablePushNotifications() { if (BuildConfig.USES_PUSH_NOTIFICATIONS) { - String token = com.google.firebase.iid.FirebaseInstanceId.getInstance().getToken(); + String token = MessagingService.getInstanceToken(); tuskyAPI.register(getBaseUrl(), getAccessToken(), token).enqueue(new Callback() { @Override public void onResponse(Call call, retrofit2.Response response) {