Golang: Send GCM- Google Cloud Message to Android Device

By Ketan Parmar Go Language No Comments on Golang: Send GCM- Google Cloud Message to Android Device

Assumption:

  1. Go lang is installed in your computer
  2. Android sample application with GCM support

Step1: Generate server API key for GCM, This article will help you to generate server API key: https://support.clevertap.com/docs/android/how-to-find-your-gcm-sender-id-and-gcm-api-server-key.html

Step2: Install Go library for GCM

Step3: Write the following function in your main.go, replace server API key in the following function. You can provide multiple client tokens in “regIDs” in case, you would like to broadcast message to multiple devices.

Step4: Call “SentGCMToClient” function from main function. replace client token in the following function

Step5: Compile & Run

Full Source code main.go

go-gcm document: https://godoc.org/github.com/google/go-gcm

  • Share:

Leave a comment