我创建了一个96x96大小的图像,根据这些信息在所有方面给出了4px的填充.
然后我使用Android Asset Studio为不同的屏幕生成图标.但是当我在我的Notification Builder中使用它时,它显示一个灰色框.我哪里做错了?
这是我的形象.无法在此处显示,因为背景是透明的,图像是白色的.请下载查看.
我正在尝试从 Firebase 控制台发送推送通知,目前我可以从 Firebase 控制台向我的虚拟设备发送消息,但如果消息很长,则不会完全显示在通知栏中。
这是 Firebasemessagingservice 的代码:
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import com.google.firebase.messaging.RemoteMessage;
/**
* Created by filipp on 5/23/2016.
*/
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService{
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
showNotification(remoteMessage.getData().get("message"));
}
private void showNotification(String message) {
Intent i = new Intent(this,MainActivity.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)
.setAutoCancel(true)
.setContentTitle("Elit")
.setContentText(message)
//.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
}
Run Code Online (Sandbox Code Playgroud)
感谢 Adib 的详细回答,我已经有一个 PHP 后端服务器,但是每当我尝试从服务器发送长通知时,它都不会完全显示,我的问题是我是否可以只编辑代码的最后一部分,以便我可以发送长通知使用 inboxStyle 或 …
android push-notification android-notifications firebase firebase-notifications
有人有经验吗?我正在调查迁移,但由于我们已经在GCM上发布了应用程序,每天有成千上万的用户和数千个通知,我不愿意因为害怕破坏现有服务.有人管理平稳过渡吗?
具体来说,在教程(https://developers.google.com/cloud-messaging/android/android-migrate-fcm)中,第一步是"导入Google项目".这是单向操作吗?现有的GCM服务器解决方案和部署的GCM应用程序是否会继续运行?
或者,最好的办法是创建一个新项目,并维护两个服务器解决方案,直到GCM部署的应用程序逐步淘汰?
今天在开发Android应用程序时,在logcat中收到以下错误消息:
您的目标是 Android Oreo 并使用自适应图标,而没有为 FCM 通知设置后备可绘制对象。这可能会导致使用 Oreo 的设备发生不可逆转的崩溃。要了解有关此问题的更多信息,请检查:https : //issuetracker.google.com/issues/68716460
我花了一段时间来追查其含义和该怎么做,所以我在下面添加了一个答案。