Reputation: 6782
I'm using Firebase to send notifications to users who installed my app. After a while some (not many) of them stop receiving notifications although they didn't unsubscribed.
I have a class that suppose to refresh then token, so I have no idea what can cause that.
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
}
}
Any idea? Thanks
Upvotes: 0
Views: 1199
Reputation: 3800
Try the code snippet below:
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
if(null != refreshedToken) {
FirebaseMessaging.getInstance().subscribeToTopic("news");
}
}
Upvotes: 2
Reputation: 1116
Have you declared the service in your manifest, like so?
<service android:name="MyFirebaseInstanceIDService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
Upvotes: 0