use of com.yellowmessenger.sdk.utils.PreferencesManager in project yellowmessenger-sdk by yellowmessenger.
the class FirebaseService method onTokenRefresh.
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
super.onTokenRefresh();
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// Save the Token in Preferences
Context context = getApplicationContext();
PreferencesManager prefManager = PreferencesManager.getInstance(context);
prefManager.setFirebaseDeviceID(refreshedToken);
XMPPUser xmppUser = prefManager.getXMPPUser();
if (xmppUser != null && xmppUser.getUsername() != null) {
String authToken = prefManager.getAuthorizationToken();
if (authToken != null) {
NotificationUtil.sendDeviceTokenToServer(refreshedToken, xmppUser.getUsername(), authToken, context);
}
}
}
Aggregations