显示FCM大型通知图标

时间:2018-01-25 11:38:05

标签: android firebase firebase-cloud-messaging

我是android新手。我创建了FCM大型通知。现在我想做什么,我怎么能像图像大图像一样通知我试图让它成为大图标,但我提交了。谢谢你的帮助。

enter image description here

FcmMessagingService:java

private void ManualNotification(String title, String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    Bundle bundle = new Bundle();
    bundle.putString("message", messageBody);
    intent.putExtras(bundle);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
    Bitmap bmp = BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher);
    Notification.BigPictureStyle bigpicture = new Notification.BigPictureStyle();
    bigpicture.bigPicture(bmp);
    NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notifcation)
            .setContentTitle(title)
            //.setContentText(messageBody)
            .setLargeIcon(bmp)
            .setContentIntent(pendingIntent)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
            .setContentText(messageBody).setLights(Color.YELLOW, 300, 300)
            .setVibrate(new long[]{100, 250})
            .setDefaults(Notification.DEFAULT_SOUND)
            .setAutoCancel(true);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, notificationBuilder.build());
}

2 个答案:

答案 0 :(得分:1)

您可以使用此链接获取通知图标大小:

notification icon size in android

或者如果要创建自定义通知视图,则可以使用RemoteView。见样本:

android custom notification tutorial

答案 1 :(得分:0)

尝试 addCandidateloginFormData(candLoginFormData : CandidateRegForm){ let headers = new Headers({'Content-Type':'application/json'}); let options = new RequestOptions({ headers : headers }); return this._http.post(this._postUrl, JSON.stringify(candLoginFormData), options) .map((response:Response) => response.json()); } **This is function called in component** registerCandidateRegForm(value : CandidateRegForm){ console.log(value); this._candidateLoginService.addCandidateloginFormData(value) .subscribe(resNewCandidateRegFormData =>{ this.candidateRegForm.push(resNewCandidateRegFormData); console.log(resNewCandidateRegFormData); }, error => { console.log(error.status); }); 课程:

Notification