chat21 / chat21-android-sdk

Android Chat SDK built on Firebase
http://www.chat21.org
MIT License
233 stars 98 forks source link

Hi guys, i want to ask how to provide FCM token. #34

Open SemenPapazov opened 5 years ago

SemenPapazov commented 5 years ago

In my logs in firebase there are such a message "There are no notification tokens to send to".

crisiscore commented 4 years ago

How about now? How do you solve that?

Bobbykart commented 4 years ago

FirebaseInstanceIdService is deprecated which you need to update manually to make it work.

  1. In .notifications.ChatFirebaseMessagingService you need to copy the onTokenChange from instanceid.service.SaveFirebaseInstanceIdService. Then you can delete SaveFirebaseInstanceIdService.class.

  2. change the onTokenChange() to onNewToken().

  3. Search for the classes: .core.ChatManager ; .core.authentication.ChatAuthentication; .core.authentication.task.RefreshFirebaseInstanceIdTask

  4. Change String token = FirebaseInstanceId.getInstance().getToken(); to FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() { @Override public void onSuccess(InstanceIdResult instanceIdResult) { String newToken = instanceIdResult.getToken(); Log.i(TAG_TOKEN, "RefreshFirebaseInstanceIdTask: token == " + newToken); } });

  5. in AndroidManifest delete `service android:name=".instanceid.service.SaveFirebaseInstanceIdService">

    </service>`