简体   繁体   中英

Small Thumbnail in Collapsed Notification with Notification Content Extension

Look a this picture:

在此处输入图片说明

Is it possible to have a small picture in the collapsed received remote notification (just like shown, in the picture, in the first phone on the left) but by using a Notification Content Extension (not the Notification Service Extension)?

I've been trying to do this with my Notification Content Extension but I only see the picture in the expanded mode of the notification (in the picture, the one on the phones on the center and right).

Thanks!

No, it is not possible in the Notification Content Extension. And it make sense because Notification Content Extension is invoked only when the notification has appeared on the device and the user has expanded it.

Notification Service extension is invoked before the Notification is presented on the device and this is where you have the APIs available to mutate the notification as well. You need to attach a media object to the notification object for the system to display the thumbnail.

However, you may use Notification Service Extension and Content Extension together for enhancing your push experience. While you can add the attachment to the push notification in the Service Extension, you may use them for custom drawing in the Content Extension.

It looks like it's not possible to have a thumbnail in the Notification when using Notification Content Extension .

So what I did was to create a Notification Service Extension and it worked out.

If you need an example about how to implemente this Notification Service Extension , check these:

  1. General Procedure: how to display image in ios push notification?

  2. DidReceive method: https://github.com/maquannene/UserNotifications/blob/master/NotificationService/NotificationService.swift

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM