我正在尝试实现bigpicturystyle,但它行不通。推动消息可行,但没有大图像。图像URL不是空的。我发送了Adobe Management的推动。还尝试使用远程视图,但也无法使用。请帮助!
public class FCMListenerService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
/*call sendNotification*/
}
private void sendNotification(String title,
String message,
String type,
String id,
String deepLink,
final String imageUrl,
Bundle fbPushBundle) {
Intent intent = new Intent(this, LoginActivity.class);
if (fbPushBundle != null)
intent.putExtra("push", fbPushBundle);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (deepLink != null && !deepLink.isEmpty()) {
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse(type);
intent.setData(uri);
}
intent.putExtra("type", type);
intent.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_push_app_icon))
.setSmallIcon(R.mipmap.ic_push_icon)
.setContentTitle(title)
.setContentText(message)
.setColor(ContextCompat.getColor(FCMListenerService.this, R.color.theme_yellow))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setDefaults(Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE)
.setContentIntent(pendingIntent);
Bitmap largeImage = null;
if (imageUrl != null) {
try {
largeImage = Picasso.with(this).load(imageUrl).get();
if (largeImage!=null){
notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(largeImage));
}
} catch (Exception e) {
e.printStackTrace();
}
}
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify((int) System.currentTimeMillis(), notificationBuilder.build());
}
}
已解决这只是奇怪的小米通知。有必要使用两个手指扩展通知
尝试包括内容和标题
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(img).setSummaryText(content).setBigContentTitle(msg))