You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/messaging/apple-integration.mdx
+78-15Lines changed: 78 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,18 @@
1
1
---
2
-
title: iOS Messaging Integration
3
-
sidebar_label: iOS Integration
4
-
description: iOS requires additional configuration steps to be completed before you can receive messages.
2
+
title: FCM via APNs Integration
3
+
sidebar_label: Apple Integration
4
+
description: iOS & macOS require additional configuration steps to be completed before you can receive messages.
5
5
---
6
6
7
-
Integrating the Cloud Messaging plugin on iOS devices requires additional setup before your devices receive messages.
7
+
:::caution
8
+
This guide applies to both iOS & macOS Flutter apps, repeat each step for the platforms you require. E.g. if you support iOS & macOS then you will need to integrate twice, once per platform Xcode project.
9
+
:::
10
+
11
+
Integrating the Cloud Messaging plugin on iOS & macOS devices requires additional setup before your devices receive messages.
8
12
There are also a number of prerequisites which are required to be able to enable messaging:
9
13
10
14
- You must have an active [Apple Developer Account](https://developer.apple.com/membercenter/index.action).
11
-
-You must have a physical iOS device to receive messages.
15
+
-For iOS; you must have a physical iOS device to receive messages.
12
16
- Firebase Cloud Messaging integrates with the [Apple Push Notification service (APNs)](https://developer.apple.com/notifications/),
13
17
however APNs only works with real devices.
14
18
@@ -17,7 +21,7 @@ There are also a number of prerequisites which are required to be able to enable
17
21
Before your application can start to receive messages, you must explicitly enable "Push Notifications" and "Background Modes"
18
22
within Xcode.
19
23
20
-
Open your project workspace file via Xcode (`/ios/Runner.xcworkspace`). Once open, follow the steps below:
24
+
Open your project workspace file via Xcode (`/{ios|macos}/Runner.xcworkspace`). Once open, follow the steps below:
21
25
22
26
1. Select your project.
23
27
2. Select the project target.
@@ -38,7 +42,7 @@ Next the "Push Notifications" capability needs to be added to the project. This
38
42
Once selected, the capability will be shown below the other enabled capabilities. If no option appears when searching, the
39
43
capability may already be enabled.
40
44
41
-
### Enable Background Modes
45
+
### Enable Background Modes (iOS only)
42
46
43
47
Next the "Background Modes" capability needs to be enabled, along with both the "Background fetch" and "Remote notifications" sub-modes.
44
48
This can be added via the "Capability" option on the "Signing & Capabilities" tab:
@@ -55,7 +59,7 @@ Now ensure that both the "Background fetch" and the "Remote notifications" sub-m
> If you want to know more about the specifics of this setup read the [official Firebase docs](https://firebase.google.com/docs/cloud-messaging/ios/send-image).
163
+
164
+
On Apple devices, in order for incoming FCM [Notifications](notifications.mdx) to display images from the FCM payload, you must add an additional notification
165
+
service extension. This is not a required step.
166
+
167
+
### Step 1 - Add a notification service extension
168
+
169
+
- From Xcode top menu go to: **File > New > Target...**
170
+
- A modal will present a list of possible targets, scroll down or use the filter to select "Notification Service Extension". Press Next.
171
+
- Add a product name (use `ImageNotification` to follow along) and click **Finish**.
172
+
- Enable the scheme by clicking **Activate**.
173
+
174
+

175
+
176
+
### Step 2 - Add target to the Podfile
177
+
178
+
Ensure that your new extension has access to Firebase/Messaging pod by adding it in the Podfile:
179
+
180
+
- From the Navigator open the Podfile: Pods > Podfile
181
+
- Scroll down to the bottom of the file and add:
182
+
```ruby
183
+
target 'ImageNotification'do
184
+
pod 'Firebase/Messaging'
185
+
end
186
+
```
187
+
188
+
- Install or update your pods using `pod install` from the `ios` and/or `macos` directory.
189
+
190
+

191
+
192
+
### Step 3 - Use the extension helper
193
+
194
+
At this point everything should still be running normally. This is the final step which is invoking the extension helper.
195
+
196
+
- From the navigator select your `ImageNotification` extension
197
+
- Open the `NotificationService.m` file
198
+
- At the top of the file import `FirebaseMessaging.h` right after the `NotificationService.h` as shown below:
199
+
```diff
200
+
#import "NotificationService.h"
201
+
+ #import "FirebaseMessaging.h"
202
+
```
203
+
- Replace everything from line 25 to 28 with the extension helper:

213
+
214
+
### Step 4
215
+
216
+
Your device can now display images in a notification by specifying the `imageUrl` option in your FCM payload. Keep in mind that a 300KB max image size is enforced by the device.
217
+
155
218
## Next steps
156
219
157
-
Once the above has been completed, you're ready to get started receiving messages on your iOS device for both
220
+
Once the above has been completed, you're ready to get started receiving messages on your iOS and/or macOS device for both
158
221
testing and production.
159
222
160
-
> Usage documentation will be available once the Firebase Firebase Cloud Messaging plugin update lands as part of the [FlutterFire roadmap](https://github.com/FirebaseExtended/flutterfire/issues/2582).
223
+
View the [Usage documentation](usage.mdx) to get started.
0 commit comments