Moves out-of-place Firebase InstanceId call to the google build flavor. Closes #274

main
Vavassor 8 years ago
parent c16c95d7a7
commit bf8d7384db
  1. 5
      app/src/fdroid/java/com/keylesspalace/tusky/MessagingService.java
  2. 5
      app/src/google/java/com/keylesspalace/tusky/MessagingService.java
  3. 2
      app/src/main/java/com/keylesspalace/tusky/BaseActivity.java

@ -134,4 +134,9 @@ public class MessagingService extends IntentService {
.putStringSet("current_ids", currentIds) .putStringSet("current_ids", currentIds)
.apply(); .apply();
} }
public static String getInstanceToken() {
// This is only used for the "google" build flavor, so this version is just a stub method.
return null;
}
} }

@ -25,6 +25,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Spanned; import android.text.Spanned;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage; import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -125,4 +126,8 @@ public class MessagingService extends FirebaseMessagingService {
mastodonAPI = retrofit.create(MastodonAPI.class); mastodonAPI = retrofit.create(MastodonAPI.class);
} }
public static String getInstanceToken() {
return FirebaseInstanceId.getInstance().getToken();
}
} }

@ -204,7 +204,7 @@ public class BaseActivity extends AppCompatActivity {
protected void enablePushNotifications() { protected void enablePushNotifications() {
if (BuildConfig.USES_PUSH_NOTIFICATIONS) { 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<ResponseBody>() { tuskyAPI.register(getBaseUrl(), getAccessToken(), token).enqueue(new Callback<ResponseBody>() {
@Override @Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) { public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {

Loading…
Cancel
Save