• Stars
    star
    176
  • Rank 212,728 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Google Cloud Messaging for application servers implemented using the Go programming language.

gcm

NOTE: I no longer maintain this library. Feel free to fork! :)

The Android SDK provides a nice convenience library (com.google.android.gcm.server) that greatly simplifies the interaction between Java-based application servers and Google's GCM servers. However, Google has not provided much support for application servers implemented in languages other than Java, specifically those written in the Go programming language. The gcm package helps to fill in this gap, providing a simple interface for sending GCM messages and automatically retrying requests in case of service unavailability.

Documentation: http://godoc.org/github.com/alexjlockwood/gcm

Getting Started

To install gcm, use go get:

go get github.com/alexjlockwood/gcm

Import gcm with the following:

import "github.com/alexjlockwood/gcm"

Sample Usage

Here is a quick sample illustrating how to send a message to the GCM server:

package main

import (
	"fmt"
	"net/http"

	"github.com/alexjlockwood/gcm"
)

func main() {
	// Create the message to be sent.
	data := map[string]interface{}{"score": "5x1", "time": "15:10"}
	regIDs := []string{"4", "8", "15", "16", "23", "42"}
	msg := gcm.NewMessage(data, regIDs...)

	// Create a Sender to send the message.
	sender := &gcm.Sender{ApiKey: "sample_api_key"}

	// Send the message and receive the response after at most two retries.
	response, err := sender.Send(msg, 2)
	if err != nil {
		fmt.Println("Failed to send message:", err)
		return
	}

	/* ... */
}

Note for Google AppEngine users

If your application server runs on Google AppEngine, you must import the appengine/urlfetch package and create the Sender as follows:

package sample

import (
	"appengine"
	"appengine/urlfetch"

	"github.com/alexjlockwood/gcm"
)

func handler(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	client := urlfetch.Client(c)
	sender := &gcm.Sender{ApiKey: "sample_api_key", Http: client}

	/* ... */
}        

More Repositories

1

ShapeShifter

SVG icon animation tool for Android, iOS, and the web
TypeScript
3,895
star
2

avocado

🥑 Vector Drawable optimization tool 🥑
TypeScript
1,287
star
3

kyrie

🍀 Animated Vector Drawables on steroids 🍀
Kotlin
1,067
star
4

adp-delightful-details

This sample app accompanies a blog post I wrote on icon animations
Java
1,044
star
5

adp-activity-transitions

This sample app accompanies a series of blog posts I wrote on transitions in Android
Java
540
star
6

bees-and-bombs-compose

Implementing some cool animations using Jetpack Compose
Kotlin
380
star
7

android-2048-compose

2048 implemented using Jetpack Compose
Kotlin
333
star
8

adp-applistloader

Tutorial: AppListLoader (part 4)
Java
238
star
9

adp-path-morph-submission-status

Submission status path morphing example
Java
210
star
10

adp-worker-fragments

Handling Configuration Changes with Fragments
Java
206
star
11

android-lint-checks-demo

A demo project that shows how to setup and write some basic custom lint checks.
Kotlin
150
star
12

adp-nested-scrolling

Sample app for the Android Design Patterns blog post on nested scrolling.
Java
136
star
13

AndroidDesignPatterns

Android Design Patterns
JavaScript
134
star
14

custom-lollipop-transitions

Java
65
star
15

svg2vd

SVG to VectorDrawable command line tool
TypeScript
47
star
16

floating-camera

Basic implementation of a floating camera view that can draw on top of other applications. Uses the same APIs that Facebook uses to implement Chatheads.
Java
46
star
17

adp-leaky-threads

Activitys, Threads, & Memory Leaks
Java
33
star
18

android-2048-strings

A repository containing all of the strings for the 2048++ application.
24
star
19

adp-contextcompat-getcolor

Java
16
star
20

godesignpatterns

Go Design Patterns
CSS
15
star
21

adp-contact-list-compose

A simple animatable contact list implemented with 100% Jetpack Compose. Written for a blog post that maybe I will finish some day...
Kotlin
13
star
22

adp-theming-buttons-with-themeoverlays

Java
9
star
23

lost-temple-analyzer

TypeScript
9
star
24

roll-off-club

Source code for the Roll Off Club site
HTML
6
star
25

arch-component-sample

Java
6
star
26

WindowInsetsPlayground

In which I figure out how window insets and status bars work on Android
Kotlin
5
star
27

15440-project3

Distributed multiplayer air hockey! Includes an Android client application (written in Java) and a distributed server (written in Go).
Java
3
star
28

network-buffer

An Android project for my networks practicum class (15-446) at CMU.
Java
2
star
29

scouting-manager-2012

Scouting Manager Android Application (as of March, 2012)
Java
2
star
30

droidcon-2017

TypeScript
1
star
31

scouting-manager-2013

Java
1
star