mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
insuring single push sent per device
This commit is contained in:
parent
047f524824
commit
3bfce5e40c
@ -52,12 +52,18 @@ func SendPushEvent(account store.Account, event string) {
|
||||
ErrMsg(err);
|
||||
return
|
||||
}
|
||||
|
||||
tokens := make(map[string]bool)
|
||||
for rows.Next() {
|
||||
var pushToken string
|
||||
var messageTitle string
|
||||
var messageBody string
|
||||
|
||||
rows.Scan(&pushToken, &messageTitle, &messageBody)
|
||||
|
||||
if _, exists := tokens[pushToken]; !exists {
|
||||
tokens[pushToken] = true;
|
||||
|
||||
url := "https://fcm.googleapis.com/fcm/send"
|
||||
payload := Payload{ Title: messageTitle, Body: messageBody, Sound: "default" };
|
||||
message := Message{ Notification: payload, To: pushToken };
|
||||
@ -85,4 +91,5 @@ func SendPushEvent(account store.Account, event string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user