Messaging Cloug Firebase sends only once

Asked

Viewed 22 times

1

Hi. I have an Android app that uses Cloud Messages, however, I noticed that I have some APP’s that the message does not arrive. For example, I have active X Apps in the playstore, but Firebase shows me a different amount of Send. My device, for example, arrives only 1 time, and in other devices I do tests (Android 10) arrives correctly.

My Androidmanifest.xml

<service
            android:name=".MyFirebaseMessagingService"
            android:exported="false"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <service
            android:name=".MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

Myfirebaseinstanceidservice.java class

package com.joel.a0800restinga;

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceIdService;

import static android.content.ContentValues.TAG;

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { @Override public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    //sendRegistrationToServer(refreshedToken);
}
} 

Myfirebasemessagingservice.java class

package com.joel.a0800restinga;

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceIdReceiver; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

private static final String TAG = "MESSAGE_FB";

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // ...


    Log.d(TAG, "From: " + remoteMessage.getFrom());

    // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
        Log.d(TAG, "Message data payload: " + remoteMessage.getData());

        if (/* Check if data needs to be processed by long running job */ true) {
            // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
            //scheduleJob();
        } else {
            // Handle message within 10 seconds
            //handleNow();
        }

    }

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
    }

    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
}
} 
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.