Is it possible that from the firebase message it shows certain content in the app?

0

Is it possible that from the firebase message it shows certain content in the app?

package juegos.example.com.appwfb;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.firebase.messaging.RemoteMessage;


    public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MyFirebaseMessagingService fbb = new MyFirebaseMessagingService();
        fbb.onMessageReceived();
    }
}

In another class

package juegos.example.com.appwfb;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.e("FIREBASE", remoteMessage.getNotification().getBody());
    }

    public void onMessageReceived() {

    }
}
    
asked by Luis Angel Tamayo 17.07.2018 в 23:07
source

1 answer

0

First of all, I recommend you read the Firebase push notifications documentation as I suggest that you are doing is wrong. The messaging service is not manually initialized from an Activity but it registers in the manifest so that your application can receive messages even when it is closed.

Once you're receiving Firebase push messages, it's simply a matter of showing a Notification with the message you want.

    
answered by 23.07.2018 в 16:19