Notificações push com carrossel de imagens para iOS
O protocolo UNNotificationContentExtension fornece o ponto de entrada para uma extensão de aplicativo de conteúdo de notificação, que exibe uma interface personalizada para as notificações do seu aplicativo.
1. Adicionar Extensão de Conteúdo de Notificação
Anchor link toNo Xcode, selecione File > New > Target…

Escolha a Notification Content Extension

Nomeie-a como NotificationContentExtension

2. Adicionar código ao seu aplicativo
Anchor link toBaixe o PWNotificationExtension do Github e substitua o PWNotificationContentExtension no seu Projeto Xcode pelo mesmo arquivo do Github.

3. Categoria de notificação
Anchor link toAdicione o código abaixo ao seu arquivo AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) { let options: UNAuthorizationOptions = [.alert] UNUserNotificationCenter.current().requestAuthorization(options: options) { (authorized, error) in if authorized { let categoryIdentifier = "PWNotificationCarousel" let carouselNext = UNNotificationAction(identifier: "PWNotificationCarousel.next", title: "➡️ RIGHT", options: []) let carouselPrevious = UNNotificationAction(identifier: "PWNotificationCarousel.previous", title: "⬅️ LEFT", options: []) let carouselCategory = UNNotificationCategory(identifier: categoryIdentifier, actions: [carouselNext, carouselPrevious], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([carouselCategory]) } } }
return true }4. Enviar uma notificação push
Anchor link toCategoria iOS:
Envie uma notificação push com o JSON da APS:

{ "aps":{ "category":"PWNotificationCarousel" }}Dados Personalizados
Você deve listar as URLs das imagens separadas por uma vírgula ,

{ "images":"image1.jpg, image2.jpg, image3.jpg"}Assim que receber o push, você precisará pressionar longamente ou deslizar para a esquerda e clicar em “View” para expandir a notificação, dependendo da versão do iOS.