I implemented Firebase for push notifications in my Android app. I implemented two services for registering a token and for creating a notification when it is detected. When my application starts, it works, but when my application is closed, it does not work.
public class FirebaseinstanceIdService extends FirebaseInstanceIdService { @Override public void onTokenRefresh() { String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.e("Firebase", refreshedToken); MainActivity.setFirebaseToken(refreshedToken); } } public class MyFirebaseMessageService extends FirebaseMessagingService { private static final String TAG = "MyFirebaseMsgService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) {
And my manifest:
<service android:name=".FirebaseinstanceIdService"> <intent-filter> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> <service android:name=".MyFirebaseMessageService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service>
And my request:
{ "to": "ex1CtVz5bbE:APA91bHiM_BCun62A9iCobF1yV26Dwn-hYCDhkYPoWEG5ZdqH0P28UsE5q1v7QibwAX7AJ290-9en9L6f548_2b7WEbJ8RPEWlIotLczjjCP7xEOWqeJk6Iz44vilWYvdu4chPwfsvXD", "data": { "title": "Notification", "body": "Message", } }
I already found some solutions in StackOverflow, but in my case this does not work. I have an API that calls an API request message: https://fcm.googleapis.com/fcm/send
So, there is my question: Does Firebase process a push notification when the application is closed and how?
thank you for your responses
source share