79512141

Date: 2025-03-16 05:14:47
Score: 0.5
Natty:
Report link

No, basically there are two major changes. you can follow this guide here

  1. Authentication: for python you can follow this code to get TOKEN

    def get_access_token():
     """Get an access token from the service account."""
     credentials = service_account.Credentials.from_service_account_file(
         FIREBASE_CONFIG,
         scopes=["https://www.googleapis.com/auth/firebase.messaging"]
     )
    
     # Refresh the token
     credentials.refresh(Request())
     return credentials.token
    

    Replace FIREBASE_CONFIG with path to serviceAccountKey.json file

  2. To send FCM messages via post man

    • URL is now changed to https://fcm.googleapis.com/v1/projects/{PROJECT_NAME}/messages:send

    • Set header Authorization: Bearer {TOKEN}

    • Add Payload

      {
          "message": {
              "token": {DEVICE_TOKEN},
              "notification": {
                  "title": "Test Notification",
                  "body": "This is a test notification with an image."
              },
              "apns": {
                  "payload": {
                      "aps": {
                          "mutable-content": 1,
                          "sound": "default"
                      }
                  }
              },
              "data": {
                  "image": "https://www.equitytool.org/wp-content/uploads/2015/06/SmallSample.png"
              }
          }
      }
      

      Replace DEVICE_TOKEN with FCM device token, mutable-content:1 is set to invoke NotificationServiceExtension in iOS.
      To send multiple deviceTokens, you can make use for multicast endpoint

Reasons:
  • Blacklisted phrase (1): this guide
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: efqz11