Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Using Notification.Badge causes FCM to reject the push notification #15

@vendion

Description

@vendion

Using fcm v0.4.0 setting Notification.Badge causes FCM to reject the push notification with a error code of 200.

Example code:

package main

import (
	"log"

	"github.com/edganiukov/fcm"
)

func main() {
	// Create the message to be sent.
	msg := &fcm.Message{
		Token: "sample_device_token",
		Notification: &fcm.Notification{
			Title: "Test Message",
			Body:  "This is a test message with a badge set",
			Badge: "/images/fcm-icon.png",
		},
	}

	// Create a FCM client to send the message.
	client, err := fcm.NewClient("sample_api_key")
	if err != nil {
		log.Fatal(err)
	}

	// Send the message and receive the response without retries.
	response, err := client.Send(msg)
	if err != nil {
		/* ... */
	}
	log.Printf("resp: %v", response)
}

response:

{"multicast_id":,"success":0,"failure":1,"canonical_ids":0,"error_code":200,"results":[{"message_id":"","registration_id":"","error":null}]}

If I use Notification.Icon instead of Notification.Badge then the message is accepted and delivered without issue but the badge on the notification is the Android default "ringing bell" instead of the desired app icen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions