GCM library for Go.

Related tags

Cryptography go-gcm
Overview

Project status

status: inactive

This project is no longer actively maintained, and remains here as an archive of this work.

For a replacement, check out this actively maintained fork of the library.

GCM Library for Go

Provides the following functionality for Google Cloud Messaging:

  1. Sending messages.
  2. Listening to receiving messages.

Documentation: http://godoc.org/github.com/google/go-gcm

Installation

$ go get github.com/google/go-gcm

Status

This library is in Alpha. We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.

Feedback

Please read CONTRIBUTING and raise issues here in Github.

Issues
  • Listen connection dropping - use model

    Listen connection dropping - use model

    This is more of a usage question. I have started using this code in a server to listen to incoming GCM messages. I noticed that the GCM's stopped reaching my server suddenly but on restarting the server I got all the queued up GCM's. I am guessing that the listen connection had dropped in the night.

    Should the the gcm.Listen call be in a forever loop like so:

    func (r *Receiver) startListener() {
        for {
            err := gcm.Listen(r.gcmSenderId, r.googleApiKey, messageHandler, stopChannel)
            revel.INFO.Println("Restarted listener because of err", err)
        }
    }
    
    opened by kuchlous 12
  • FCM

    FCM

    What about: Firebase Cloud Messaging (FCM) is the new version of GCM. It inherits the reliable and scalable GCM infrastructure, plus new features! See the FAQ to learn more. If you are integrating messaging in a new app, start with FCM. GCM users are strongly recommended to upgrade to FCM, in order to benefit from new FCM features today and in the future.

    How to use FCM endpoints? fcm.googleapis.com/fcm/ and fcm-xmpp.googleapis.com

    opened by Andrushk 5
  • Fix #33 MessageId is a signed int

    Fix #33 MessageId is a signed int

    Details in #33

    cla: yes 
    opened by tevjef 4
  • Potential problem with TimeToLive field in HttpMessage and XmppMessage

    Potential problem with TimeToLive field in HttpMessage and XmppMessage

    Hi folks, I noticed that the TimeToLive field in the message structs is tagged as `json:"time_to_live,omitempty". From what I understand, this means that if TimeToLive has the default value (zero), then it will be omitted when marshaling the struct. If this is indeed the case (and according to my tests it is), then there is a discrepancy in the time_to_live usage, according to [https://developers.google.com/cloud-messaging/http-server-ref]: time_to_live = 0, means that the notification should not be throttled and delivered immediately, and if this is not possible, then it should be discarded. However if I set TimeToLive = 0, it will be omitted from the message sent to the GCM server, and then the server will assume the default value, which is 4 weeks -- clearly, not what my intention was.

    opened by karapas 4
  • Bubble up CCS ack replies.

    Bubble up CCS ack replies.

    Successful replies (acks) should be also bubbled in order to enable custom handling of canonical registration_id. Also deleting message from the message log if nacked and `not retriable, otherwise it will stay there forever.

    cla: no 
    opened by bolshoy 3
  • Synchronization rework

    Synchronization rework

    Fixed race conditions under heavy load by carefully tuned locking. Removed safeMap, which was a wrong choice. Tested under heavy load in dry mode.

    cla: yes 
    opened by bolshoy 2
  • Corrected upstream stanza types.

    Corrected upstream stanza types.

    • apparently, Ack and Nack do not have a stanza type, fixed the relevant switch
    • added Ack to server receipts
    • exposed ack/nack/control/receipt constants to be used in the listener code
    cla: yes 
    opened by bolshoy 2
  • Bubble up CCS ack replies.

    Bubble up CCS ack replies.

    Successful replies (acks) should be also bubbled in order to enable custom handling of canonical registration_id. Also deleting message from the message log if nacked and `not retriable, otherwise it will stay there forever.

    cla: no 
    opened by bolshoy 1
  • Error=DeprecatedEndpoint

    Error=DeprecatedEndpoint

    There are two problems with this library 1.you must change Priority in HttpMessage struct in file gcm.go to int 2.if every things is ok but you get error Error=DeprecatedEndpoint go to gcm.go again and on const section change httpAddress from this "https://gcm-http.googleapis.com/gcm/send" to "https://fcm.googleapis.com/fcm/send"

    opened by mohamadpk 0
  • Changed httpHost for Firebase notifications.

    Changed httpHost for Firebase notifications.

    Changed httpHost for Firebase notifications.

    cla: no 
    opened by BasilSnowman 2
  • bugfix: invalid parsing of response

    bugfix: invalid parsing of response

    If sender id is not valid, server response in html format. But error message said about error of parsing json

    example:

    <HTML>
    <HEAD>
        <TITLE>Invalid (legacy) Server-key delivered or Sender is not authorized to perform request.</TITLE>
    </HEAD>
    <BODY BGCOLOR=\ "#FFFFFF\" TEXT=\ "#000000\">
        <H1>Invalid (legacy) Server-key delivered or Sender is not authorized to perform request.</H1>
        <H2>Error 401</H2>
    </BODY>
    </HTML>
    
    opened by khevse 0
  • Add staging support.

    Add staging support.

    This PR introduces an isProduction flag to allow switching between production and staging xmpp addresses.

    cla: yes 
    opened by cscatolini 5
  • Support configuration of the xmppAddress

    Support configuration of the xmppAddress

    xmppAddress is currently defined as a constant (https://sourcegraph.com/github.com/google/go-gcm/-/blob/gcm.go#L42) - this prevents clients from specifying the pre-prod server at gcm-preprod.googleapis.com:5236, or (more importantly for my use-case) connecting to the newer fcm-xmpp.googleapis.com:5235

    opened by froodian 1
  • sample code

    sample code

    Can someone post a sample code of basic use of this library.(Listen , Send, Receive)

    opened by billidani7 0
  • Long multicast_id

    Long multicast_id

    After attempt to send message:

    gcm.SendHttp(apiKey, message)

    I'm receiving error:

    error sending request to GCM HTTP server: error unmarshaling json from body: json: cannot unmarshal number 7168156478862157292 into Go value of type int

    DebugMode = true:

    sending:{"to":"dQmz...CRyA","data":{"message":"hello world"}} received body:{"multicast_id":7168156478862157292,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1469779167530028%d86f1c9df9fd7ecd"}]}

    May be is necessary to change the type of HttpResponse.MulticastId to int64 or string?

    opened by Andrushk 1
  • accept appengine users

    accept appengine users

    usage:

    import ( "github.com/google/go-gcm" "net/http" "appengine" "appengine/urlfetch" )

    var key = "your api key"

    c := appengine.NewContext(r) client := urlfetch.Client(c) gcm.Client = client m := gcm.HttpMessage{RegistrationIds: regIDs, Data: data} _, err := gcm.SendHttp(key, m)

    cla: yes 
    opened by matsuoky 1
  • Proper error handling when sending XMPP message

    Proper error handling when sending XMPP message

    Recently, SendXmpp() started failing for me with the following error:

    write tcp <IP>:<port>-><IP>:<port>: write: connection timed out
    

    Restarting the Go process that called SendXmpp() makes this error go away, and push notifications start working again. But of course, restarting the Go process isn't ideal. Is there something I can do explicitly to handle this kind of error? For instance, is there a way to close the current XmppClient and retry sending the message, so that the retry instantiates a new XmppClient and opens a new connection?

    opened by jedlau 0
  • Refactored and improved project

    Refactored and improved project

    @silvolu please take a look at our fork https://github.com/rounds/go-gcm

    • code refactored, http and xmpp clients separated
    • monitors xmpp connection with xmpp pings, redials when it fails
    • handles CONNECTION_DRAINING properly
    • graceful close
    • improved logging with logrus
    • various govet/golint fixes
    • Travis and Codecov added

    The project runs in production for a couple of months, looks good)

    opened by bolshoy 11
Owner
Google Archive
Where old projects go to retire. All projects here are completely frozen, though feel free to fork and continue using them on your own.
Google Archive
This library generate a new tlsconfig usable within go standard library configured with a self-signed certificate generated on the fly

sslcert This library generate a new tlsconfig usable within go standard library configured with a self-signed certificate generated on the fly. Exampl

ProjectDiscovery 6 Nov 17, 2021
This library aims to make it easier to interact with Ethereum through de Go programming language by adding a layer of abstraction through a new client on top of the go-ethereum library.

Simple ethereum client Simple ethereum client aims to make it easier for the developers to interact with Ethereum through a new layer of abstraction t

Jero 1 Jan 9, 2022
Port of Google's Keyczar cryptography library to Go

Important note: Keyczar is deprecated. The Keyczar developers recommend Tink. This is a port of Google's Keyczar library to Go. Copyright (c) 2011 Dam

Damian Gryski 112 Feb 4, 2021
whirlpool cryptographic hashing library

whirlpool.go A whirlpool hashing library for go Build status Setup $ go get github.com/jzelinskie/whirlpool Example package main import ( "fmt" "

Jimmy Zelinskie 20 Jan 27, 2021
Golang Library for automatic LetsEncrypt SSL Certificates

Obtains certificates automatically, and manages renewal and hot reload for your Golang application. It uses the LEGO Library to perform ACME challenges, and the mkcert utility to generate self-signed trusted certificates for local development.

Foomo web framework 152 Jan 7, 2022
Pure Go Kerberos library for clients and services

gokrb5 It is recommended to use the latest version: Development will be focused on the latest major version. New features will only be targeted at thi

Jonathan Turner 545 Jan 17, 2022
:key: Idiotproof golang password validation library inspired by Python's passlib

passlib for go 100% modules-free. Python's passlib is quite an amazing library. I'm not sure there's a password library in existence with more thought

Hugo Landau 260 Jan 10, 2022
A convenience library for generating, comparing and inspecting password hashes using the scrypt KDF in Go 🔑

simple-scrypt simple-scrypt provides a convenience wrapper around Go's existing scrypt package that makes it easier to securely derive strong keys ("h

Matt Silverlock 173 Nov 9, 2021
A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.

Filippo Valsorda 9.7k Jan 15, 2022
Easy to use encryption library for Go

encryptedbox EncryptedBox is an easy to use module for Go that can encrypt or sign any type of data. It is especially useful when you must serialize y

Jesse Swidler 18 Oct 26, 2021
Pure Go GOST cryptographic functions library.

Pure Go GOST cryptographic functions library. GOST is GOvernment STandard of Russian Federation (and Soviet Union). GOST 28147-89 (RFC 5830) block cip

Pedro Albanese 1 Dec 20, 2021
A Golang cryptocurrency trading API & Library. Support Binance, BitMEX, Deribit, Bybit, Huobi DM, OKEX Futures and more.

CREX 中文 | English CREX 是一个用Golang语言开发的量化交易库。支持tick级别数字币期货平台的回测和实盘。实盘与回测无缝切换,无需更改代码。 回测 示例 @backtest 交易结果 开源策略 https://github.com/coinrust/trading-stra

Paranoid 1 Oct 22, 2021
A Go library to create hashes with a builtin expiration

ExpiringLink This is a simple library for creating unique strings that have a built in expiration. The target use case is web links for password reset

Bill Moran 5 Nov 1, 2021
Ethermint is a scalable and interoperable Ethereum library, built on Proof-of-Stake with fast-finality using the Cosmos SDK.

Ethermint Ethermint is a scalable and interoperable Ethereum library, built on Proof-of-Stake with fast-finality using the Cosmos SDK which runs on to

Tharsis 1.6k Jan 22, 2022
The go-to Bitcoin Node (BN) Go library.

go-bitcoin Go wrapper for bitcoin RPC RPC services Start by creating a connection to a bitcoin node b, err := New("rcp host", rpc port, "rpc usernam

null 2 Jan 17, 2022
A golang library to use aes encrypt easier.

Aes a golang library to use aes encrypt easier. Install go get github.com/hanson/aes Document import import github.com/hanson/aes CBC orig := "hello

null 2 Dec 3, 2021
Simple aio library to download Spanish electricity hourly prices (PVPC) from esios.ree.es

aiopvpc Simple aio library to download Spanish electricity hourly prices. Made to support the pvpc_hourly_pricing HomeAssistant integration. Install I

Eugenio Panadero 24 Dec 26, 2021
OpenZeppelin Contracts is a library for secure smart contract development.

A library for secure smart contract development. Build on a solid foundation of community-vetted code. Implementations of standards like ERC20 and ERC

OpenZeppelin 15.2k Jan 19, 2022
Asu-go2js - Asu is a library to work with subtitles on ASS format.

asu-go2js Asu is a library to work with subtitles on ASS format. asu-go2js is a port of Asu (originally for .NET) written in Go and compiled to JavaSc

Eduardo Hinojosa (Frost) 0 Jan 8, 2022