use of app.insti.api.request.UserFCMPatchRequest in project IITB-App by wncc.
the class MainActivity method updateFCMId.
/**
* Update FCM Id and update profile
*/
private void updateFCMId() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
final String fcmId = instanceIdResult.getToken();
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.patchUserMe(Utils.getSessionIDHeader(), new UserFCMPatchRequest(fcmId, getCurrentVersion())).enqueue(new EmptyCallback<User>() {
@Override
public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) {
session.createLoginSession(response.body().getUserName(), response.body(), session.getSessionID());
currentUser = response.body();
Utils.currentUserCache = currentUser;
} else {
session.logout();
currentUser = null;
Toast.makeText(MainActivity.this, "Your session has expired!", Toast.LENGTH_LONG).show();
}
}
});
}
});
}
Aggregations