HelloGCM
A really simple example to demonstrate how to use GCM
Steps to use the example project:
- Create a
google-services
configuration file here. Insert the package name as "com.alphabet7.hellogcm" if you don't change the package name in this project. - Save your
SENDER_ID
andSERVER_KEY
informations. - Download the
google-services.json
file then save it to the/app
folder. - Insert your
SENDER_ID
at theGcmRegistrationIntentService.java
. - Run the project, check the Android Monitor, and wait for the Registration Token to appear in the Log.
- Use postman with the template here, and insert your
SERVER_KEY
andDEVICE_REGISTRATION_TOKEN/ID
in the Body and Header. Alternatively, you can also use this website, insert theSERVER_KEY
,DEVICE_REGISTRATION_TOKEN/ID
, and this message:{"content":"Congratulations, GCM push success"}
. Then click Submit/Send. - The push notification will appear on your device.
HelloGCM (Bahasa Indonesia)
Contoh sederhana untuk menggunakan GCM (Google Cloud Messaging)
Langkah-langkah untuk menjalankan project ini:
- Buat file konfigurasi
google-services
di sini. Masukkan package name-nya sebagai "com.alphabet7.hellogcm" jika kamu tidak mau merubah package name pada project ini. - Simpan data
SENDER_ID
danSERVER_KEY
yang diberikan. - Unduh file
google-services.json
kemudian simpan di folder/app
project ini. - Masukkan data
SENDER_ID
kamu padaGcmRegistrationIntentService.java
. - Run project ini, buka Android Monitor, kemudian tunggu sampai Registration Token Device-nya muncul di Log.
- Gunakan Postman dengan template berikut, lalu masukkan data
SERVER_KEY
danDEVICE_REGISTRATION_TOKEN/ID
-nya pada Body dan Header. Selain cara itu, kamu juga bisa menggunakan website ini, masukkanSERVER_KEY
,DEVICE_REGISTRATION_TOKEN/ID
, dan message ini:{"content":"Congratulations, GCM push success"}
. Lalu klik Submit/Send - Push Notification akan tampil di device kamu.