DimitarStoyanoff / Notifications

FCM Notifications with images in app foreground
61 stars 41 forks source link

A code in the article is different from repository #7

Closed CoolMind closed 5 years ago

CoolMind commented 5 years ago

For instance, in the article you have a deprecated class MyFirebaseInstanceIDService and there:

@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);
    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    preferences.edit().putString(Constants.FIREBASE_TOKEN, refreshedToken).apply();
    }
}

This code is useful for me to get current token, but it is also deprecated, see https://stackoverflow.com/questions/51125169/what-to-use-now-that-firebaseinstanceid-getinstance-gettoken-is-deprecated.

DimitarStoyanoff commented 5 years ago

Hello @CoolMind , Thank you for noticing this. Unfortunately due to certain circumstances I am currently unable to update the article. That is why I am keeping the repository updated, and I have taken those things into account. Aside from this change, the rest of the tutorial is still useful and applicable. Especially when it comes to the Firebase API, that information cannot be seen in the repo, and that is why the article still exists. As you can see, I have also updated the codebase entirely to Kotlin, so I am trying to keep it as updated as possible, and I will continue supporting this repo, because that is all I can do at the moment. I would suggest sticking to this repo when implementing logic. Thank you again for your support.

CoolMind commented 5 years ago

Hello, @DimitarStoyanoff! Thank you very much! Your code helped me in many situations. Currently I am researching an application visibility. When a push notification is clicked and an application is in foreground, a navigation gets more complex. So, I try to use https://stackoverflow.com/questions/3667022/checking-if-an-android-application-is-running-in-the-background/ with ProcessLifecycleOwner. This information will be outdated, if a user will click a push message later than it will be delivered on a device. You make a good job, thank you for your support!