小编Hüs*_*MAZ的帖子

Firebase云消息传递不起作用

我正试图在我的申请上显示通知.我在Firebase控制台上创建了一个应用程序.注意:没有错误.当我从Firebase控制台发送消息后启动应用程序时,没有任何内容出现.这有什么不对?

MyFireBaseInstaceIDService.java

package com.example.hp.mesajlasma;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

private static final String TAG = "MyFirebaseIIDService";

/**
 * Called if InstanceID token is updated. This may occur if the security of
 * the previous token had been compromised. Note that this is called when the InstanceID token
 * is initially generated so this is where you would retrieve the token.
 */
// [START refresh_token]
@Override
public void onTokenRefresh() {
    // Get updated InstanceID …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging

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

应用程序运行时不显示Firebase通知

这是我的代码

 private void showNotification(String message) {

    NotificationCompat.BigTextStyle stil = new NotificationCompat.BigTextStyle();
    stil.setBigContentTitle("Ba??l");
    stil.bigText(message);
    Intent i=new Intent(this,Bilgi.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent=PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.mipmap.ic_launcher);
    builder.setTicker("selam dost.mesaj geldi");
    builder.setDefaults(Notification.DEFAULT_ALL);
    builder.setContentIntent(pendingIntent);
    builder.setContentTitle("Bildirim");
    builder.setContentText(message);
    builder.setStyle(stil);
    NotificationManager notificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0,builder.build());



}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

当我发送通知时(如果应用程序正在工作(图片的左侧)),我的通知不会显示.当应用程序在后台工作时,我的通知显示.我怎么解决这个问题 ?非常感谢你的帮助.

android firebase firebase-cloud-messaging firebase-notifications

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