Api 28中不推荐使用FirebaseInstanceIdService

时间:2018-10-08 11:42:41

标签: java android

FirebaseInstanceIdService已弃用

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = MyFirebaseInstanceIDService.class.getSimpleName();

@Override
public void onTokenRefresh() {
    super.onTokenRefresh();
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();

    // Saving reg id to shared preferences
    storeRegIdInPref(refreshedToken);

    // sending reg id to your server
    sendRegistrationToServer(refreshedToken);

    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(AppConfig.REGISTRATION_COMPLETE);
    registrationComplete.putExtra("token", refreshedToken);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

private void sendRegistrationToServer(final String token) {
    // sending gcm token to server
    Log.e(TAG, "sendRegistrationToServer: " + token);
}

}

0 个答案:

没有答案