-
Notifications
You must be signed in to change notification settings - Fork 2.3k
docs(messaging): add step-by-step instructions for image notification #4225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mikehardy
merged 11 commits into
invertase:master
from
davidepalazzo:docs-notifications-with-image
Sep 12, 2020
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0de0a4
docs(messaging, notifications-with-image): add instruction for Notifi…
davidepalazzo 138c2f1
docs(messaging, notifications-with-image): correct a couple of things
davidepalazzo 579cf17
docs(messaging, notifications, server-integrations): edit pagination
davidepalazzo 8347a1f
docs(messaging, notifications): add Podfile to spellcheck
davidepalazzo 7d2bf6d
docs(messaging, notifications): add newly created Notifications with …
davidepalazzo 3aa92ad
Update docs/sidebar.yaml
mikehardy 395ba79
Apply suggestions from code review
mikehardy 01435f9
chore(images): add assets folder for docs' images
davidepalazzo 41a0a65
chore(images): moving images into the 'static' folder
davidepalazzo 5d560b0
docs(messaging): renamed md file to match page title, update paginati…
davidepalazzo 68f10e7
docs(messaging): reference images in the static folder
davidepalazzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ OpenID | |
| perf | ||
| performant | ||
| personalization | ||
| Podfile | ||
| plist | ||
| pre-fetched | ||
| pre-rendered | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| title: Notifications with Image | ||
| description: Displaying an image in a notification. | ||
mikehardy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| next: /messaging/server-integration | ||
| previous: /messaging/notifications | ||
| --- | ||
|
|
||
| This is a quick guide to display an image in an incoming notification. Android handles this out of the box so this extra setup is **only necessary for iOS**. | ||
|
|
||
| > 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). | ||
| **🚨 Before you start** | ||
| Be sure you already have Cloud Messaging installed and set up. In case you don't [get started here](/messaging/usage). | ||
|
|
||
| **🏁 Ready to start** | ||
| The following steps will guide you through how to add a new target to your application to support payloads with an image. Open Xcode and let's get started. | ||
|
|
||
| ### Step 1 - Add a notification service extension | ||
|
|
||
| - From Xcode top menu go to: **File > New > Target...** | ||
| - A modal will present a list of possible targets, scroll down or use the filter to select `Notification Service Extension`. Press **Next**. | ||
| - Add a product name (use `ImageNotification` to follow along) and click **Finish** | ||
| - Enable the scheme by clicking **Activate** | ||
|
|
||
|  | ||
|
|
||
| ### Step 2 - Add target to the Podfile | ||
|
|
||
| Ensure that your new extension has access to Firebase/Messaging pod by adding it in the Podfile: | ||
| - From the Navigator open the Podfile: **Pods > Podfile** | ||
| - Scroll down to the bottom of the file and add | ||
|
|
||
| ```Ruby | ||
| target 'ImageNotification' do | ||
| pod 'Firebase/Messaging', '~> VERSION_NUMBER' # eg 6.31.0 | ||
| 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 3 - Use the extension helper | ||
|
|
||
| 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.m` file | ||
| - At the top of the file import `FirebaseMessaging.h` right after the `NotificationService.h` as shown below | ||
|
|
||
| ```diff | ||
| #import "NotificationService.h" | ||
| + #import "FirebaseMessaging.h" | ||
| ``` | ||
|
|
||
| - then replace everything from line 25 to 28 with the extension helper | ||
|
|
||
| ```diff | ||
| - // Modify the notification content here... | ||
| - self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title]; | ||
|
|
||
| - self.contentHandler(self.bestAttemptContent); | ||
| + [[FIRMessaging extensionHelper] populateNotificationContent:self.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). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.