Configure Google FCM

Last Updated on : 2024-03-20 07:06:06download

This topic describes how to configure Google Firebase Cloud Messaging (FCM) to implement push notifications in an app for Android.

Configure Google Firebase

  • If this is your first time configuring Google FCM push, perform the following steps.
  • If your app has been configured with an old version of FCM push before, you need to find the original project and go directly to Step 12. You do not need to update and launch the app.
  • If your app has been configured with an old version of FCM before, but the original project cannot be found, follow the steps in sequence. The app needs to be built and updated before being launched.
  1. Go to Google Firebase and follow the instructions to register an account and log in to Google Firebase.

  2. Click Create a project.

    Configure Google FCM
  3. Enter your project name, tick the two check boxes, and click Continue.

    Configure Google FCM
  4. Click the toggle switch to disable Enable Google Analytics for this project and click Create project.

    Configure Google FCM
  5. After the project is created, click Continue.

    Configure Google FCM
  6. On the page of Project Overview, click the Android logo as denoted in the figure.

    Configure Google FCM
  7. Fill in the package name of your app in the Android package name field and click Register app.

    • Android package name: Recommended format of the package name is com.xxx.xxx.
    • App nickname: Optional.

    The package name must be correct. Otherwise, push notifications cannot be received.

    Configure Google FCM
  8. Click Next.

    Configure Google FCM Configure Google FCM
  9. Click Continue to console.

    Configure Google FCM
  10. In the top left corner of the console, click ⚙️ on the right of Project Overview and select Project settings.

    Configure Google FCM

  11. Choose General > google-services.json to download this file.

    Configure Google FCM

  12. Select the Service accounts tab and click Generate new private key.

    Configure Google FCM
  13. Click Generate key and the browser will automatically download a JSON file. If the file is not downloaded, check whether the browser is blocking it.

    Configure Google FCM Configure Google FCM

    You have downloaded two JSON files. Please save them separately.

Upload to the Tuya IoT Development Platform

  1. Log in to the Tuya IoT Development Platform.

  2. In the left-side navigation pane, choose App > Required Setting.

    If you have multiple apps, you can click Change App to choose a desired app.

    Configure Google FCM
  3. Click the Certificate for Android tab, scroll down the page, and find **Push Certificate for Android ** > Configure Google FCM.

    Configure Google FCM
  4. Upload the two JSON files you have downloaded.

    • Firebase Private Key: Upload the JSON file downloaded from the Service accounts page as instructed in Step 12.
    • Client Private Key: Upload the JSON file downloaded from the General page as instructed in Step 11.