firebase-admin-go icon indicating copy to clipboard operation
firebase-admin-go copied to clipboard

No sound - iOs Payload received by devices misses Sound field

Open borjamunozf opened this issue 9 months ago • 0 comments
trafficstars

Hello.

I'm having issues getting sound for the notifciations sent to IOS Devices. The devices receives the notification but without sound.

func buildIOSMessage() *messaging.Message {
	tokenDecrypted, err := decrypt(iosToken)
	if err != nil {
		log.Fatal("fatal decrypt")
	}
	// Prepare IOS message
	message := &messaging.Message{
		Token: tokenDecrypted,
		Notification: &messaging.Notification{
			Title: "whatever",
			Body:  "body"
		},
		APNS: &messaging.APNSConfig{
			Headers: map[string]string{
				"apns-priority": "10", // High priority
			},
			Payload: &messaging.APNSPayload{
				Aps: &messaging.Aps{
					Alert: &messaging.ApsAlert{
						Title: "whatever"
						Body:  "body"
					},
					Sound:          "default",

				},
				CustomData: map[string]interface{}{
					"extra_super_data": "whatever",
				},
			},
		},
	}
	return message
}

	client, err := app.Messaging(ctx)
       	res, err := client.Send(ctx, message)

       if err != nil {
		log.Fatalf("Failed to sent message: %v", err)
	}

	log.Println(res)
	log.Println("Firebase messaging client created successfully")

However, if I sent it through Firebase console, it works. If we compare the payload received in both cases:

  • Not working
{
  "gcm.message_id": "whatever",
  "google.c.a.e": "1",
  "google.c.sender.id": "whatever",
  "aps": {
    "alert": {
      "title": "quefacemos",
      "body": "SONIDOSONIDOSONIDO"
    }
  },
  "google.c.fid": "whatever",
  "extra_super_data": "whatever"
}
  • Firebase console message - working
{
  "google.c.a.c_l": "Test sound",
  "google.c.a.c_id": "whatver",
  "google.c.sender.id": "whatever",
  "google.c.a.ts": "whatv",
  "gcm.n.e": "1",
  "gcm.message_id": "whatever",
  "google.c.a.e": "1",
  "google.c.fid": "whatever",
  "aps": {
    "alert": "Test sound",
    "sound": "default",
    "mutable-content": 1
  },
  "google.c.a.udt": "0",
  "gcm.notification.sound2": "default"
}

Anyone could help me? Thanks

borjamunozf avatar Feb 19 '25 12:02 borjamunozf