Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No sound - iOs Payload received by devices misses Sound field #673

Open
borjamunozf opened this issue Feb 19, 2025 · 0 comments
Open

No sound - iOs Payload received by devices misses Sound field #673

borjamunozf opened this issue Feb 19, 2025 · 0 comments

Comments

@borjamunozf
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant