相关疑难解决方法(0)

如何在应用程序处于前台时处理火基通知

我已将Fire基础云消息传递与我的应用程序集成.当我从firebase控制台发送通知时,如果app处于后台/未打开,那么我收到通知,

但当应用处于前台/开放时无法接收通知

所有建议都表示赞赏.

android broadcastreceiver firebase-cloud-messaging

21
推荐指数
2
解决办法
3万
查看次数

Android - 收到通知但没有通知弹出窗口(前景)

我的应用正在正确接收通知,但未能显示收到信息的通知(如果应用已打开).

注意:如果应用程序在后台,则会显示通知而不会出现任何问题.


我的代码:

我收到此方法的通知:

@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
    Log.d(TAG, "From: " + remoteMessage.getFrom());

    if(remoteMessage!=null)
    {
        String id = null;
        String title = null;
        String body = null;
        String launchPage = null;

        if(remoteMessage.getNotification()!=null)
        {
            title = remoteMessage.getNotification().getTitle();
            body = remoteMessage.getNotification().getBody();
        }

        if(remoteMessage.getMessageId()!=null)
        {
            id = remoteMessage.getMessageId();
        }

        Log.i(TAG, "id: " + id);
        Log.i(TAG, "title: "+ title);
        Log.i(TAG, "body: " + body);

        int notif_id = 0;

        sendNotification(notif_id, title, body, launchPage);
    }
}
Run Code Online (Sandbox Code Playgroud)

然后它调用这个(它应该显示我理解的通知):

private void sendNotification(int id, String title, String …
Run Code Online (Sandbox Code Playgroud)

notifications android firebase google-cloud-messaging

1
推荐指数
1
解决办法
828
查看次数