diff --git a/docs/messaging/ios-notification-images.md b/docs/messaging/ios-notification-images.md index 334002c0e5..656617da04 100644 --- a/docs/messaging/ios-notification-images.md +++ b/docs/messaging/ios-notification-images.md @@ -43,7 +43,9 @@ end ![step-2](/assets/docs/messaging/ios-notification-images-step-2.gif) -### Step 3 - Use the extension helper +### Step 3 - Use the extension helper (Objective-C) + +> If you selected to create your extension as a Swift project, jump to the next section. At this point everything should still be running normally. This is the final step which is invoking the extension helper. @@ -68,6 +70,34 @@ At this point everything should still be running normally. This is the final ste ![step-3](/assets/docs/messaging/ios-notification-images-step-3.gif) +### Step 3 - Use the extension helper (Swift) + +At this point everything should still be running normally. This is the final step which is invoking the extension helper. + +- From the navigator select your `ImageNotification` extension +- Open the `NotificationService.swift` file +- At the top of the file import `Firebase` right after the `NotificationService` as shown below + +```diff +import UserNotifications ++ import Firebase + +class NotificationService: UNNotificationServiceExtension { +``` + +- then replace everything from line 19 to 23 with the extension helper + +```diff + if let bestAttemptContent = bestAttemptContent { +- // Modify the notification content here... +- bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" +- +- contentHandler(bestAttemptContent) ++ Messaging.serviceExtension() ++ .populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler) + } +``` + ## All done Run the app and check it builds successfully – **make sure you have the correct target selected**. Now you can use the [Notifications composer](https://console.firebase.google.com/u/0/project/_/notification) to test sending notifications with an image (`300KB` max size). You can also create custom notifications via [`FCM HTTP`](https://firebase.google.com/docs/cloud-messaging/http-server-ref) or [`firebase-admin`](https://www.npmjs.com/package/firebase-admin). Read this page to send [messages from a server](/messaging/server-integration).