pushserver

module
v0.1.5-0...-9a2956c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2019 License: MIT

README

PushServer

GoDoc

This project was forked from github.com/appleboy/go-fcm.git.

Golang client library for Firebase Cloud Messaging. Implemented only HTTP client.

More information on Firebase Cloud Messaging

Feature

  • Send messages to a topic
  • Send messages to a device list
  • Supports condition attribute (fcm only)

Getting Started

  1. To install fcm :
go get github.com/blockchain207/PushServer
  1. To install mysql :
go get -u github.com/go-sql-driver/mysql
  1. Add Firebase admin SDK :
go get firebase.google.com/go

Sample Usage

  • Go MySQL Driver is an implementation of Go's database/sql/driver interface. You only need to import the driver and can use the full database/sql API then:
package main
 
import (
    "database/sql" 
    _ "github.com/go-sql-driver/mysql"
    "log"
)
 
func main() {
    db, err := sql.Open("mysql", "root:pwd@tcp(127.0.0.1:3306)/testdb")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()
     
    //...(use db)....
}
  • Here is a simple example illustrating how to use FCM library:
package main

import (
	"log"

	"github.com/appleboy/go-fcm"
)

func main() {
	// Create the message to be sent.
	msg := &fcm.Message{
		To: "sample_device_token",
		Data: map[string]interface{}{
			"foo": "bar",
		},
	}

	// Create a FCM client to send the message.
	client, err := fcm.NewClient("sample_api_key")
	if err != nil {
		log.Fatalln(err)
	}

	// Send the message and receive the response without retries.
	response, err := client.Send(msg)
	if err != nil {
		log.Fatalln(err)
	}

	log.Printf("%#v\n", response)
}
  • Parse json Golang:
{

  "database": {
        "platform": "mysql",
        "info": "user.name:user.password@tcp(user.ip:user.port)/db.name"
  },
    
  "firebase": {
        "serverKey": "sample_api_key"
  },
  
  "time": {
        "second": 30
  }
  
}

Directories

Path Synopsis
common

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL