2016-11-19 207 views

回答

2
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` 
     } 

    } 

试试这个效果很酷。

+0

谢谢兄弟们..作品... – veer

1

你的问题很模糊,你可以通过简单的搜索fcm golang或其他东西来回答它。基本上,这里的库的列表:

https://golanglibs.com/top?q=firebase

好像大多有一些例子+文档。 我想一般来讲去与最流行的:

https://github.com/zabawaba99/firego

因为你可以从GitHub问题激发自己和文档是一种体面:

https://godoc.org/gopkg.in/zabawaba99/firego.v1

小记,如果任何去图书馆似乎缺乏示例/文档尝试在文件夹中运行godoc或(甚至更快),尝试首先在github页面上查找GoDocs链接。