In this tutorial we assume that you have already made the certificates to publish your app in the App Store.
- Login to the Apple Developer Program
- Click in Certificates, Identifiers & Profiles > Identifiers
- Now click on + to add new identifier
- Select
App IDsand continue - Select type
Appand continue - For the
DescriptionwriteAppName Notification Serviceor whatever you want - For the
Bundle IDwriteapp.package.name.NotificationServicean set inExplicit - In
Capabilitiesleave those selected by default, it is possible that if your main package usesAssociated Domainsyou have to activate it here - Click now in continue to save identifier
- Go now to Profiles
- Now click on + to create new profile
- Select
App Storeand continue - Select you
app.package.name.NotificationServiceand continue - From the list, select the certificate you are currently using to sign your app for the App Store and continue
- For the
Provisioning Profile NamewriteAppName Notification Service Profileor whatever you want - Now click in Generate
- First, download the new Profile with Xcode > Preferences... > Accounts > Download Manual Profiles
- In you xCode project, select File > New > Target and select
Notification Service Extension - For the
Product NamewriteNotificationService - Select in
LanguagetheSwift
- Replace the content of the created
NotificationService.swiftwith the content of NotificationService.swift
- Change the
provisioningProfilefrom youbuild.jsonto an array with both profiles{"app.package.name":"00000000-0000-0000-0000-000000000000", "app.package.name.NotificationService":"00000000-0000-0000-0000-000000000000"}
Now you can send notifications with images using the following payload:
{
"name": "my_notification",
"notification": {
"body": "Notification body",
"title": "Notification title"
},
"data": {
"notification_foreground": "true",
"notification_ios_image_jpg": "https://...",
"notification_ios_image_png": "https://...",
"notification_ios_image_gif": "https://...",
}
}