【发布时间】:2019-05-30 11:25:39
【问题描述】:
我正在从 Firebase 控制台推送通知。我能够轻松接收通知数据并且通知也会出现,但我要做的是更改通知的小图标和大图标。
我正在使用这两种方法,但它们似乎都不起作用。我还尝试通过res>New>Vector>Clip Art 使用Vector 选项制作小图标。
既不出现小图标,也不出现大图标,通知也无法展开。
MessagingService.kt
class MessagingService(): FirebaseMessagingService() {
override fun onMessageReceived(p0: RemoteMessage ? ) {
super.onMessageReceived(p0)
showNotification(p0!!.notification!!.title!!, p0!!.notification!!.body!!)
}
fun showNotification(title: String, body: String) {
val icon = BitmapFactory.decodeResource(resources,
R.drawable.iphn)
NotificationCompat.Builder(this, "MyNotifications")
.setLargeIcon(icon)
.setSmallIcon(R.drawable.ic_notif)
.setContentTitle(title)
.setContentText(body)
.setStyle(NotificationCompat.BigPictureStyle()
.bigPicture(icon)
.bigLargeIcon(null))
.build()
}
}
ic_notif是我使用Vector创建的drawable
【问题讨论】:
标签: java android kotlin push-notification android-notifications