Skip to content

Commit 10e618f

Browse files
Merge branch 'main' into v8-deprecations
2 parents 86a128d + 9d2817b commit 10e618f

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

docs/messaging/ios-notification-images.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ target 'ImageNotification' do
3838
end
3939
```
4040

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

4443
![step-2](/assets/docs/messaging/ios-notification-images-step-2.gif)
4544

46-
### Step 3 - Use the extension helper
45+
### Step 3 - Use the extension helper (Objective-C)
46+
47+
> If you selected to create your extension as a Swift project, jump to the next section.
4748
4849
At this point everything should still be running normally. This is the final step which is invoking the extension helper.
4950

@@ -68,6 +69,34 @@ At this point everything should still be running normally. This is the final ste
6869

6970
![step-3](/assets/docs/messaging/ios-notification-images-step-3.gif)
7071

72+
### Step 3 - Use the extension helper (Swift)
73+
74+
At this point everything should still be running normally. This is the final step which is invoking the extension helper.
75+
76+
- From the navigator select your `ImageNotification` extension
77+
- Open the `NotificationService.swift` file
78+
- At the top of the file import `Firebase` right after the `NotificationService` as shown below
79+
80+
```diff
81+
import UserNotifications
82+
+ import Firebase
83+
84+
class NotificationService: UNNotificationServiceExtension {
85+
```
86+
87+
- then replace everything from line 19 to 23 with the extension helper
88+
89+
```diff
90+
if let bestAttemptContent = bestAttemptContent {
91+
- // Modify the notification content here...
92+
- bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
93+
-
94+
- contentHandler(bestAttemptContent)
95+
+ Messaging.serviceExtension()
96+
+ .populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
97+
}
98+
```
99+
71100
## All done
72101

73102
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 commit comments

Comments
 (0)