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

This commit is contained in:
Vavassor 2017-05-07 16:14:28 -04:00
parent 31fff630f3
commit 8787cf6beb
3 changed files with 11 additions and 1 deletions

View File

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

View File

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

View File

@ -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<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, retrofit2.Response<ResponseBody> response) {