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
docs(firebase pn): Update Push Notifications with Firebase Guide (#2698)
- References to Ionic 5 instead of Ionic 4.
- Prompts to install the '@ionic/cli' instead of previous 'ionic' cli package.
- Reminds user to build and copy web assets to capacitor after writing code.
- Adds instructions on Android app creation
Copy file name to clipboardExpand all lines: site/docs-md/guides/push-notifications-firebase.md
+36-18Lines changed: 36 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,12 @@ description: Learn how to get Firebase Cloud Messaging working on iOS and Androi
4
4
url: /docs/guides/push-notifications-firebase
5
5
contributors:
6
6
- bryplano
7
+
- javebratt
7
8
---
8
9
9
10
# Using Push Notifications with Firebase in an Ionic + Angular App
10
11
11
-
**Web Framework**: Ionic 4 + Angular
12
+
**Web Framework**: Angular
12
13
**Platforms**: iOS, Android
13
14
14
15
One of the most common features provided by application developers to their users is push notifications. In this tutorial, we'll walk through all the steps needed to get [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) working on iOS and Android.
@@ -21,16 +22,21 @@ Building and deploying iOS and Android applications using Capacitor requires a b
21
22
22
23
To test push notifications on iOS, Apple requires that you have [a paid Apple Developer account](https://developer.apple.com/) and a *physical* iOS device.
23
24
25
+
If you are running into issues or your console throws warnings about outdated or deprecated packages, make sure that you're on the latest stable versions of Node, Android Studio, and Xcode.
26
+
27
+
Also, we're using Firebase for push notifications, so if you're using other Cordova plugins that use the Firebase SDK make sure they're using the latest versions.
28
+
24
29
## Prepare an Ionic Capacitor App
25
-
If you have an existing Ionic 4 app, skip this section. If not, let's create an Ionic app first.
30
+
31
+
If you have an existing Ionic app, skip this section. If not, let's create an Ionic app first.
26
32
27
33
In your preferred terminal, install the latest version of the Ionic CLI:
28
34
29
35
```bash
30
-
npm install -g ionic
36
+
npm install -g @ionic/cli
31
37
```
32
38
33
-
Next, let's use the CLI to create a new Ionic 4 Angular app based on the **blank** starter project and call it **capApp**:
39
+
Next, let's use the CLI to create a new Ionic Angular app based on the **blank** starter project and call it **capApp**:
34
40
35
41
```bash
36
42
ionic start capApp blank --type=angular
@@ -105,28 +111,28 @@ ngOnInit() {
105
111
});
106
112
107
113
// On success, we should be able to receive notifications
@@ -197,6 +203,13 @@ export class HomePage implements OnInit {
197
203
}
198
204
```
199
205
206
+
After this, you'll want to generate a new build and let Capacitor know about the changes. You can do that with:
207
+
208
+
```bash
209
+
ionic build
210
+
npxcap copy
211
+
```
212
+
200
213
## Creating a Project for your App on Firebase
201
214
202
215
Before we can connect Firebase Cloud Messaging to your application and send push notifications, you'll need to start a project in Firebase.
@@ -211,7 +224,9 @@ Name the project, accept the Firebase ToS and click **Create project** to contin
211
224
212
225
This section more-or-less mirrors the [setting up Firebase using the Firebase console documentation](https://firebase.google.com/docs/android/setup?authuser=0). See below for specific Capacitor-related notes.
213
226
214
-
Go to the Project Overview page for your Firebase project and, under the **Grow** section, click the **Cloud Messaging** option. At the top, click on the **Android** icon.
227
+
Go to the Project Overview page for your Firebase project and at the top, click on the **Android** icon to add a new android application.
228
+
229
+

215
230
216
231
The next screen will ask you for some information about your application.
217
232
@@ -270,7 +285,7 @@ You'll then want to open Xcode...
270
285
npxcapopen ios
271
286
```
272
287
273
-
... and move the `.plist` file into your Xcode project as instructed by Firebase, ensuring to add it to all targets.
288
+
... and move the `.plist` file into your Xcode project as instructed by Firebase, ensuring to add it to all targets.
274
289
275
290

@@ -377,7 +394,6 @@ If you would like to recieve the firebase FCM token from iOS instead of the raw
377
394
}
378
395
```
379
396
380
-
381
397
### UploadtheAPNSCertificateorKeyto Firebase
382
398
383
399
Ifyoufollowedtheinstructionsfromthe beginning, you'll have created an Apple APNS Certificate or an APNS Auth Key in the Apple Developer portal. You need to upload one of these to Firebase before Firebase can talk to APNS and send push notifications to your application.
@@ -395,11 +411,13 @@ Now for the fun part - let's verify that push notifications from Firebase are wo
Nowwe'll test to see if the notifications are received by our device. To send a notification, in Firebase, go to the **Cloud Messaging** section under the Grow header in the project pane.
431
+
Nowwe'll test to see if the notifications are received by our device. To send a notification, in Firebase, go to the **Cloud Messaging** section under the Grow header in the project pane.
0 commit comments