How to send firebase push notification from dropsource


#1

I’ve recently been seeing several people here asking about how to send firebase push notifications from dropsource, and even if it was possible.
This post is to show that yes it is very possible. Will find time to give detail steps how to go about it.
For now just showing a demo of sending firebase push notification from dropsource.
In the example below i first send the push notification to all users of the app.
Then i send a push notification to only a single user.

To send a firebase notification to multiple devices, you will need to subscribe the devices to a topic and send the notification to the topic.
To send to a single device you need to get the device token/id and send the notification to that token/id.
I created an api for sending the push notifications from dropsource.
Later when i provide a step by step instruction i will share the swagger specification.


#2

Thanks @seanhoots for helping out with this. :+1:


#3

Ok here are instructions for sending Firebase push notifications in dropsource.
For now i will show how to send to all users of your app.

  1. Add firebase to your app by following the instructions in step 1 of this dropsource tutorial
    Note. Your Dropsource app Package ID (in Settings) should match the one in your Firebase Console and Google Services JSON file. This is a unique name that should be different from any app


  2. Upload the send firebase push notification api into your dropsource.
    I’ve created the swagger specification for the api which you can download or copy from this link.

  3. Set the API Authorization key in Dropsource to your Firebase Web API Key.
    This is done the same way as you add Authorization token to your bubble API or other Authorization header.
    Simply add a device variable. Then on Application Launch event set the value of the device variable to your Firebase Server Key as bellow.


    Very important.
    The authorization key should be of the format key=your_web_api_key

  4. Subscribe devices to a firebase notification topic.
    To send firebase push notifications to multiple devices you have to let the devices subscribe to a topic then any message sent to that topic will be received by the subscribed devices to that topic.
    In this example since we want to send the notification to all devices, we will subscribe them to a topic which we will call all . Note that you can use any name for any topic.
    When you subscribe the device to a topic will depend on your application. But in this example i will subscribe a device whenever a user sign-up.
    To subscribe a device add the Dropsource action Subscribe to Fireibase Topic, then enter the name of the topic you want to subscribe the device to (in this case all )

  5. Set up your API request.
    Currently the API requires 3 parameters (might add more fields like custom image, data, etc when Dropsource supports them), the title, body and to (the recipient (s) of the notification.
    As the names implies, the title and body are for the title and body of the notification, respectively.
    For the to field we will specify the topic we want the notification to be sent to.
    Topics are specified in the format /topics/topic_name.
    So in our case it will be /topics/all

  6. Make the api call.
    Finally in an event (e.g. button tab) call your api using Run Request action.

That’s it.


#4

Thanks for this @seanhoots !!! :tada: :balloon: :fireworks:

So in case anyone’s unsure about how all the pieces fit together here, this will allow you to trigger notifications from your Dropsource app (and they can be sent to other users of the app as in the example) by making a request to Firebase Cloud Messaging API right?


#5

Yes @sue, you’re perfectly right. This is for triggering a push notification from Dropsource instead of doing it from a backend server.

There are several use cases where you want to trigger a push notification based on an event in an app and it may be simpler and quicker just doing it from Dropsource.
For example, think of a facebook-like app whereby you want to send a push notification to a user when their post gets a like. In this case, on tap of the like button, you can trigger the push notification request.

Also for applications that are not using backend servers capable of making rest api calls, this will come in handy. For example those using google sheets as their backend database and connecting with Sheetsu, they wont be able to make rest api calls from their backend without another third part microservice. In such situation they could rely on this for triggering push notifications right from their dropsource app in response to some events.

There are definitely other use cases where the push notification has to be triggered from a backend. Especially time-based notifications where you want to programmatically send notifications to all or some users at specific times.
Generally any push notification that is not triggered by an event in the app has to be initiated from the backend.

I will be creating a bubble plugin that will allow bubble users to trigger firebase push notifications from their backend.
There is already a bubble plugin for triggering OneSignal notifications.


#6

Got it, those are great use cases I had genuinely not thought of as being achievable without going via a backend. :thumbsup:


#10

Does this work for IOS Dropsource apps? The Dropsource Firebase tutorial only shows how to install on Android devices.


#11

We currently only support receiving firebase notifications on Android, as mentioned here:


#12

So, this was from August of 2018 - Its there still no functionality for IOS?


#13

Yes that is correct. We do not have Firebase notifications for iOS. It’s not slated to be introduced in the future.


#15

I think this example needs a little more context. If you were to say, send a push notification to just one user, then you would subscribe that user on the Dropsource side, to maybe their user ID from your database; something that would always make that topic unique to just that user. Then you would pass the user’s ID to your backend as the to param, along with the other params; that would allow you to append it to the to the to property in the field array, i.e. /topic/1. Checkout this article on stack overflow to see what that would look like.