uniqush / uniqush-push

Uniqush is a free and open source software system which provides a unified push service for server side notification to apps on mobile devices.
http://uniqush.org
Apache License 2.0
1.54k stars 201 forks source link

FCM support (refactored) #148

Closed TysonAndre closed 7 years ago

TysonAndre commented 7 years ago

Based on PR #139

This uses anonymous field (in a manner similar to subclassing, but very different) to factor out code common to GCM and FCM http://dennissuratna.com/using-anonymous-field-to-extend-in-go/

TysonAndre commented 7 years ago

This works in the emulator, and the way to set up uniqush for FCM is pretty much identical to GCM.

To set up FCM, Log in to https://console.firebase.google.com

  1. Click on settings (The gear icon)
  2. Choose the cloud messaging tab
  3. The projectid (called sender id in FCM) should be visible in the project credentials section. So should the apikey (Called "Server key" in FCM). Google recommends the longer "Server Key" over the legacy server key.
# Add the PSP, can call the service anything, e.g. myproject.fcm,
# or group it under another service
curl http://127.0.0.1:9898/addpsp -d service=myproject.fcm -d pushservicetype=fcm -d projectid=<project id>

# Add a test  subscriber programatically by calling the rest API
# E.g. https://github.com/firebase/quickstart-android/tree/master/messaging
# is a test project using FCM which gives you the id in logcat output
curl http://127.0.0.1:9898/subscribe -d service=myproject.fcm -d subscriber=uniqush.client1234 -d pushservicetype=fcm -d regid=blahblah:abcdefgabba_restofregid

# The below command sends a push over FCM
# (See the documentation for GCM, the params are almost the same.
#  The documentation can be found at http://uniqush.org/documentation/usage.html)
# The query param uniqush.payload.fcm can also be used instead to provide raw
# JSON payloads for the FCM module to send.
curl http://127.0.0.1:9898/push -d service=myproject.fcm -d subscriber=uniqush.client1234 -d msg=hello