forked from hbarnardt/fcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
55 lines (47 loc) · 1.22 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Package fcm provides integration with Firebase Cloud Notification HTTP API https://firebase.google.com/docs/cloud-messaging/http-server-ref
You can send push notifications to Android and iOS devices via simple API.
Example:
package main
import (
"fmt"
"log"
"github.com/maddevsio/fcm"
)
func main() {
data := map[string]string{
"msg": "Hello World1",
"sum": "Happy Day",
}
c := fcm.NewFCM("serverKey")
token := "token"
response, err := c.Send(&fcm.Message{
Data: data,
RegistrationIDs: []string{token},
ContentAvailable: true,
Priority: fcm.PriorityHigh,
Notification: &fcm.Notification{
Title: "Hello",
Body: "World",
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Status Code :", response.StatusCode)
fmt.Println("Success :", response.Success)
fmt.Println("Fail :", response.Fail)
fmt.Println("Canonical_ids :", response.CanonicalIDs)
fmt.Println("Topic MsgId :", response.MsgID)
}
If you want to send notification with Sound or Badge, then use:
response, err := c.Send(&fcm.Message{
Notification: &fcm.Notification{
Title: "Hello",
Body: "World",
Sound: "default",
Badge: "3",
},
})
*/
package fcm