2016-11-19 238 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鏈接。