Skip to content

Commit

Permalink
Merge branch 'main' into v8-deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Dec 20, 2024
2 parents 86a128d + 9d2817b commit 10e618f
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions docs/messaging/ios-notification-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ target 'ImageNotification' do
end
```

- Make sure to change the version number `VERSION_NUMBER` with the currently installed version (check your Podfile.lock)
- Install or update your pods using `pod install` from the `ios` folder

![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.

Expand All @@ -68,6 +69,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).

0 comments on commit 10e618f

Please sign in to comment.