Remote media
APNs supports three types of media: audio, images, and video. You can use a Notification Service Extension to download one of these media types and attach it to an incoming push notification.
AWSPinpointPushNotificationsPlugin provides a service extension that works with Amazon Pinpoint push notifications. You can use the service extension as-is or override certain methods to customize functionality. The following steps describe how to setup the provided Notification Service Extension in your project.
- In your Xcode project, select File, New, Target...
- Select Notification Service Extension and click Next.
- Enter a name for your service extension and click Finish.
- In project settings, select the service extension target you just added, select the General tab, and add AWSPinpointPushNotificationsPlugin under Frameworks and Libraries.
- When you created the service extension, Xcode created a NotificationService.swift file containing some boiler plate code. Locate this file under the service extension's folder and replace it's contents as show below:
import AWSPinpointPushNotificationsPlugin
class NotificationService: AWSPinpointPushNotificationsPlugin.ServiceExtension {}
Your service extension is now setup to fetch remote media from a URL defined in Amazon Pinpoint push notifications, save the media to a temporary folder, and attach them to push notifications before they are presented to the user.
APNs supported media types and sizes
Audio - 5MB max
- AudioInterchangeFileFormat
- WaveformAudio
- MP3
- MPEG4Audio
Image - 10 MB max
- JPEG
- GIF
- PNG
Video - 50 MB max
- MPEG
- MPEG2Video
- MPEG4
- AVIMovie