Aller au contenu principal

Firebase Push Notifications (FCM)

Push Notifications is a useful Flutter plugin. With this plugin, your Flutter app can receive and process push notifications on Android and iOS.

This guide shows you the way to setup Firebase Cloud Messaging(FCM) to push notifications.

Remember to disable OneSignal Push Notifications if you push notifications using Firebase, by:

- open the app on AppBuilder
- go to **Features** > **General** > **OneSignal** >
- turn of **Enable OneSignal** and click **Update**.

To ask for User Notification Permission at the first time opening:

1. Open your app on AppBuilder → **Features** → **General** → **Miscellaneous**
2. Enable **Request Notification Permission** → **Apply** and **Save**

1. Push Notifications in iOSundefined

Precondition: Follow Firebase Settings to create an IOS application on Firebase.

Step 1: Install Cloud Messaging to enable push notifications on iOS. Click Cloud Messaging as shown:

  • Installing Cloud Messaging requires you to upload the auth key APNs here

  • in sectionCertificates, identifiers & Profiles
  • Select Keys on the left menu, then click the plus icon to add a new key:

Note: 1 developer apple account can only create 2 keys, please consider before creating. But you can still delete them if needed.

  • Enter the Key Name and select Apple Push Notification service (APNs) then click continue

  • Click Register

  • Click Download to download the APNs key file

  • Return to the firebase console to update the APNs auth key. Click Upload

  • Click the Browse button then select the downloaded key:

  • The key ID is the back part of the downloaded key file name:

  • Enter Team ID, if you do not know where Team ID is coming from, please click on the question mark as shown in the picture, then click on the membership tab

This is Team ID, copy it and enter the form in firebase:

  • Click Upload:

In some cases, this error will be displayed (in some cases it will not be). If this is the case, please click Upload again:

If the following screen appears, congratulations, you have successfully configured:

Step 2: Get Server Key

Go to the following path Cloud Messaging and select your Firebase Console project to get Server Key

  • Click Three Dot in Left Side Firebase Cloud Messaging API Section.

  • Click Manage API in Google Cloud Console Link

  • Then Open new tab, Enable Firebase Cloud Messaging API

  • Then go back to Firebase and follow same step for Cloud Messaging API (Legacy)

  • Click Enable

  • Go Back To Firebase Cloud Messaging Tab and Refresh current page , Now You See The Server Key in Google Firebase Console

  • Input your Server Key:

Then SEND a message to push notification.

Note:

  • The Server Key taken must be the Server Key of that project.
  • Absolutely do not share Server Key.

2. Push Notifications on Androidundefined

Precondition: Follow Firebase Settings to create an Android application on Firebase.

Steps: Go to the following path Cloud Messaging and select your Firebase Console project to get Server Key

Input your Server Key:

Then SEND a message to push notification.

Note:

  • The Server Key taken must be the Server Key of that project.
  • Absolutely do not share Server Key.