firebase / firebase/firebase-admin-go

FR - make Message Data interface{} instead map[string]string to allow other data types

Open
#170 5 comments 5 reactions 1 assignee Claimed by @sampson-chen View on GitHub
api: messaging
Dominant language
Go
Stars
1.3k
Forks
274
Avg merge
10h 39m
Merged PRs (30d)
2

Description

### Describe your environment

* Firebase SDK version: 3.3.0
* Firebase Product: Messaging/Notifications

### Describe the problem

#### Steps to reproduce:

We cannot use reuse a struct in the message data and instead we create a new map[string]string to be send as Data of FCM Message Data . So we have to trim out boolean, int , float into string and reprocess them again on swift and android code from string to correct datatypes.

This is terrible approach unwrapping structs at golang code and wrapping back string json into android/iOS pojos in client code.

#### Relevant Code:

```
// TODO(you): code here to reproduce the problem
article := Article{}
article.Title = "Awww"
article.Message = "This is so much work."
article.Source = "New Delhi"
article.Debug = true
article.Version = 1

articleData := map[string]string{
"debug" : "true",
"version" : "1",
"source" : article.Source,
"title" : article.Title,
"message" : article.Message,
}

message := &messaging.Message{
Data: articleData,
Topic: "debug",
Notification: &messaging.Notification{Title: article.Title, Body: article.Message},
}

We should be instead be able to use

message := &messaging.Message{
Data: article,
Topic: "debug",
Notification: &messaging.Notification{Title: article.Title, Body: article.Message},
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.