为什么从服务器推送通知时未执行“ MyFirebaseMessagingService”类

时间:2018-12-26 10:16:50

标签: java android firebase android-studio firebase-cloud-messaging

我在Android应用包中创建了一个名为MyFirebaseMessagingService的类,该类扩展了Google FirebaseMessagingService。我已经完成了google docs中提到的所有规定步骤,但是当服务器(Laravel)发送推送通知时,我的课程没有执行。

我在android通知托盘中收到了通知,但是由于未执行此类,我无法对该通知执行任何操作:

public class MyFirebaseMessagingService extends FirebaseMessagingService
{
    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage)
    {
        super.onMessageReceived(remoteMessage);
        Toast.makeText(this,remoteMessage.getNotification().getBody().toString(),Toast.LENGTH_LONG).show();
        // here i want that whenever this class executes and this
        // onMessageReceived method is being called this toast
        // should be toasted .

    }

当我在Toast行上应用断点时,发送通知时它不会执行..

0 个答案:

没有答案