i am doing ionic apps, using cordova fcm plugin i get the device token.Now i want send the push notification from go server.please help me how use go as the fcm server.I need some implementation example
2条回答 默认 最新
- doulubashang6936 2016-11-26 11:29关注
package main import ( "fmt" "github.com/NaySoftware/go-fcm" ) const ( serverKey = "YOUR-KEY" ) func main() { var NP fcm.NotificationPayload NP.Title="hello" NP.Body="world" data := map[string]string{ "msg": "Hello World1", "sum": "Happy Day", } ids := []string{ "token1", } xds := []string{ "token5", "token6", "token7", } c := fcm.NewFcmClient(serverKey) c.NewFcmRegIdsMsg(ids, data) c.AppendDevices(xds) c.SetNotificationPayload(&NP) status, err := c.Send() if err == nil { status.PrintResults() } else { fmt.Println(err)`enter code here` } }
try this it works cool.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报