Search in sources :

Example 1 with PreferencesManager

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);
        }
    }
}
Also used : Context(android.content.Context) XMPPUser(com.yellowmessenger.sdk.models.XMPPUser) PreferencesManager(com.yellowmessenger.sdk.utils.PreferencesManager)

Aggregations

Context (android.content.Context)1 XMPPUser (com.yellowmessenger.sdk.models.XMPPUser)1 PreferencesManager (com.yellowmessenger.sdk.utils.PreferencesManager)1