# Push Notificacions with Google Firebase Notifications

**URL:** <https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910>\
**Category:** How-to Discussions\
**Created:** [September 3, 2016, 8:31am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910 "2016-09-03T08:31:04Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Saura](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/javier_saura/32/276_2.png) [@Javier\_Saura](https://forums.fusetools.com/u/Javier_Saura)\
**Post date:** [September 3, 2016, 8:31am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/1 "2016-09-03T08:31:04Z")

</div>

Hi!!

Fuse Push Notifications in Android works with Google Firebase Notifications? I would appreciate a code example if is possible…

Thanks!!

---

<div class="post-metadata">

**Author:** ![dszymczak84](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/dszymczak84/32/418_2.png) [@dszymczak84](https://forums.fusetools.com/u/dszymczak84)\
**Post date:** [November 10, 2016, 11:03pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/2 "2016-11-10T23:03:08Z")

</div>

bump!

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [November 15, 2016, 12:50pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/3 "2016-11-15T12:50:48Z")

</div>

We have not tried this. I would believe that is a different api that needs to be wrapped.

---

<div class="post-metadata">

**Author:** ![mitesh](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mitesh](https://forums.fusetools.com/u/mitesh)\
**Post date:** [December 29, 2016, 6:51am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/4 "2016-12-29T06:51:49Z")

</div>

Hello! As of November, Google is forcing all developers to use Firebase Cloud Messaging for all new apps. So we are unable to set up GCM and to our team this is a major inconvenience out of nowhere.

I believe a lot of new developers will be affected. Perhaps Fuse Team should look in to this as a priority for the Push module?

---

<div class="post-metadata">

**Author:** ![jesusmartinoza](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jesusmartinoza/32/659_2.png) [@jesusmartinoza](https://forums.fusetools.com/u/jesusmartinoza)\
**Post date:** [January 2, 2017, 8:06pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/5 "2017-01-02T20:06:29Z")

</div>

Firebase notifications it’s possible. You just have to follow the actual tutorial [https://www.fusetools.com/docs/fuse/pushnotifications/push](https://www.fusetools.com/docs/fuse/pushnotifications/push). In the Step 2. (Only for Android), create your firebase project, go to the firebase console and copy/paste the sender id.

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/iZrGgagcQpj1-image-1483387531866.jpg)

I’m still don’t implement it in iOS but I suppose it is pretty straightforward.

Cheers!

Edit: I’m trying to implement and iOS. It’s not “straightforward” x.x

---

<div class="post-metadata">

**Author:** ![mitesh](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mitesh](https://forums.fusetools.com/u/mitesh)\
**Post date:** [January 12, 2017, 5:36pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/6 "2017-01-12T17:36:30Z")

</div>

Thanks for your response! We will check it out in a few weeks. No verification yet.

---

<div class="post-metadata">

**Author:** ![itai.lewin](https://avatars.discourse-cdn.com/v4/letter/i/4491bb/32.png) [@itai.lewin](https://forums.fusetools.com/u/itai.lewin)\
**Post date:** [March 2, 2017, 7:28am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/7 "2017-03-02T07:28:22Z")

</div>

Hi,  
Any progress with push notification Fuse + Firebase on android?  
does anyone has an example to share?  
cause until it works, no way to have push notifications on Fuse.

---

<div class="post-metadata">

**Author:** ![LuisRodriguezLD](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/luisrodriguezld/32/616_2.png) [@LuisRodriguezLD](https://forums.fusetools.com/u/LuisRodriguezLD)\
**Post date:** [March 2, 2017, 3:56pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/8 "2017-03-02T15:56:30Z")

</div>

@itai.lwein:  
if you need push notifications on Android just follow Jesus Martinez advice

> **jesusmartinoza wrote:**
> 
> Firebase notifications it’s possible. You just have to follow the actual tutorial [Fuse](https://www.fusetools.com/docs/fuse/pushnotifications/push). In the Step 2. (Only for Android), create your firebase project, go to the firebase console and copy/paste the sender id.

---

<div class="post-metadata">

**Author:** ![Tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@Tom1](https://forums.fusetools.com/u/Tom1)\
**Post date:** [March 2, 2017, 4:02pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/9 "2017-03-02T16:02:14Z")

</div>

> **Luis Rodriguez wrote:**
> 
> @itai.lwein:  
> if you need push notifications on Android just follow Jesus Martinez advice
> 
> > **jesusmartinoza wrote:**
> > 
> > Firebase notifications it’s possible. You just have to follow the actual tutorial [Fuse](https://www.fusetools.com/docs/fuse/pushnotifications/push). In the Step 2. (Only for Android), create your firebase project, go to the firebase console and copy/paste the sender id.

```
push.on("receivedMessage", function(payload) {
    console.log("Recieved Push Notification: " + payload);
});

```

only shows output on console. Any way to show it on Android notification bar??. Don’t know how to use after this…

---

<div class="post-metadata">

**Author:** ![LuisRodriguezLD](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/luisrodriguezld/32/616_2.png) [@LuisRodriguezLD](https://forums.fusetools.com/u/LuisRodriguezLD)\
**Post date:** [March 2, 2017, 4:10pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/10 "2017-03-02T16:10:26Z")

</div>

@Tom, I am not 100% sure (I don’t have an Android) but someone told me you have to use `LocalNotify` for it to appear no the Notification Bar (again, android only).

After adding it to your project ([https://www.fusetools.com/docs/fuse/localnotifications/localnotify](https://www.fusetools.com/docs/fuse/localnotifications/localnotify)), give this a try and let me know what happens.

```auto
push.on("receivedMessage", function(payload) {
    console.log("Recieved Push Notification: " + payload);
    LocalNotify.now("Boom!", "Just like that", payload, true);
});

```

Ps. since I am not sure what I am doing maybe we should talk it over Slack? Add me: luisrodriguezld

---

<div class="post-metadata">

**Author:** ![itai.lewin](https://avatars.discourse-cdn.com/v4/letter/i/4491bb/32.png) [@itai.lewin](https://forums.fusetools.com/u/itai.lewin)\
**Post date:** [March 2, 2017, 7:36pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/11 "2017-03-02T19:36:03Z")

</div>

Well, did all the settings and I run this:

```auto
{
  "RootNamespace":"",
  "Packages": [
    "Fuse",
    "Fuse.PushNotifications",
    "Fuse.LocalNotifications",
    "FuseJS"
  ],
  "Includes": [
    "*"
  ],
  "Android": {

    "GooglePlay": {
        "SenderID": "mySenderID"
    }
},
}

```

and:

```auto
<App>
	<JavaScript>
			var Observable = require("FuseJS/Observable");
			var Payload = Observable("-->Payload here<--");

	    var push = require("FuseJS/Push");
			var LocalNotify = require("FuseJS/LocalNotifications");
	    push.on("registrationSucceeded", function(regID) {
	        console.log("Reg Succeeded: " + regID);
	    });

	    push.on("error", function(reason) {
	        console.log("Reg Failed: " + reason);
	    });

	    push.on("receivedMessage", function(payload) {
	        console.log("Recieved Push Notification: " + payload);
					LocalNotify.now("Boom!", "Just like that", payload, true);
					Payload.value = payload;
	    });
			module.exports = {
  			Payload:Payload
			};

	</JavaScript>
	<StackPanel>
		<Text TextAlignment="Center" Value="Payload"/>
		<Text TextAlignment="Center" Value="{Payload}"/>
	</StackPanel>

</App>

```

manage to get connection confirmation from the Firebase server, but when I try to send a message from there notifications tool, nothings happens.

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/Sh7InyhLtF3S-image-1488483588103.png)

---

<div class="post-metadata">

**Author:** ![Tom1](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@Tom1](https://forums.fusetools.com/u/Tom1)\
**Post date:** [March 4, 2017, 7:08pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/12 "2017-03-04T19:08:29Z")

</div>

```
So i manage to push the message from firebase console by targeting on single device.
but if I choose target as user segment, push notification doesn't come at all. 
I have 3 device connected. I want to send push message on all device at once.
@itai.lewin, try sending push using single device. FCM registration token is device token.

```

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/4QoOhsjWaxMd-image-1488654009560.PNG)

 ![file](https://s3.us-east-2.amazonaws.com/fuse-legacy-forum-assets/uIg82rAo4g3S-image-1488654137197.png)

---

<div class="post-metadata">

**Author:** ![itai.lewin](https://avatars.discourse-cdn.com/v4/letter/i/4491bb/32.png) [@itai.lewin](https://forums.fusetools.com/u/itai.lewin)\
**Post date:** [March 7, 2017, 2:10pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/13 "2017-03-07T14:10:56Z")

</div>

Same here, manage to make it work (kinda) only for single device (FCM registration token)  
it will force me to send for each connected device it’s FCM registration token, then send to each of the separately.  
btw, it doesn’t work on preview, only on build

---

<div class="post-metadata">

**Author:** ![amilcar](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@amilcar](https://forums.fusetools.com/u/amilcar)\
**Post date:** [March 15, 2017, 9:00am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/14 "2017-03-15T09:00:11Z")

</div>

Check this:

> Notification messages are delivered to the notification tray when the app is in the background. For apps in the foreground, messages are handled by these callbacks:
> 
> `didReceiveRemoteNotification`: on iOS
> 
> `onMessageReceived()` on Android. The notification key in the data bundle contains the notification.

**source: [About FCM messages &nbsp;|&nbsp; Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/concept-options)**

Maybe you need to convert the notification to an alert, I’m not sure, I’m new on this

> **Tom wrote:**
> 
> > **Luis Rodriguez wrote:**
> > 
> > @itai.lwein:  
> > if you need push notifications on Android just follow Jesus Martinez advice
> > 
> > > **jesusmartinoza wrote:**
> > > 
> > > Firebase notifications it’s possible. You just have to follow the actual tutorial [Fuse](https://www.fusetools.com/docs/fuse/pushnotifications/push). In the Step 2. (Only for Android), create your firebase project, go to the firebase console and copy/paste the sender id.
> 
> ```
> push.on("receivedMessage", function(payload) {
> console.log("Recieved Push Notification: " + payload);
> });
> 
> ```
> 
> only shows output on console. Any way to show it on Android notification bar??. Don’t know how to use after this…

---

<div class="post-metadata">

**Author:** ![Simo\_Santavirta](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/simo_santavirta/32/175_2.png) [@Simo\_Santavirta](https://forums.fusetools.com/u/Simo_Santavirta)\
**Post date:** [March 28, 2017, 8:19am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/15 "2017-03-28T08:19:19Z")

</div>

We are also waiting for solution to this. Firebase notifications goes to app, but not to tray.

---

<div class="post-metadata">

**Author:** ![Baggers](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/baggers/32/665_2.png) [@Baggers](https://forums.fusetools.com/u/Baggers)\
**Post date:** [March 29, 2017, 1:25pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/16 "2017-03-29T13:25:14Z")

</div>

Im currently testing to find the smallest fix to a problem we do have with firebase messages. I’m going to brainsdump here so you folks know where we are and where we are going.

* * *

### Where we were

Kinds of Message.

GCM had [two kinds of messages](https://developers.google.com/cloud-messaging/concept-options#notifications_and_data_messages) `notification` messages and `data` messages. `Notification` messages are delivered to the notification tray when the app is inactive, `data` messages are delivered to the app (even when in the background or closed).

`notification` messages had this structure:

```auto
{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "notification" : {
	"body" : "great match!",
	"title" : "Portugal vs. Denmark",
	"icon" : "myicon"
  }
}

```

`data` messages had this structure:

```auto
{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
	"Nick" : "Mario",
	"body" : "great match!",
	"Room" : "PortugalVSDenmark"
  },
}

```

[See here for more details](https://developers.google.com/cloud-messaging/concept-options#notifications_and_data_messages)

Fuse provided the following behaviour:

- if the app is in the background or closed we make a notification in the notification tray. We use data in the message to customize your notification (sound, title, body, etc)
- if the app is in the foreground we deliver the message striaght to JS with nothing in the tray

This gave us behaviour on Android that matched iOS APNs, which we felt was valuable for app similicity.

The bit that we had an example for but totally failed to explain in the tutorials was that _in order for this mechanism to work the message HAD to be a data message_

We also had the data laid out in a daft way:

```auto
...
body: JSON.stringify({
	registration_ids: [regID],
	data: {
		notification: {
			alert: {
				title: 'Well would ya look at that!',
				body: 'Hello from some other app',
				icon: 'Foo.png'
			}
		},
		payload: 'anything you like'
	}
})
...

```

### Where we are

The fact we do not handle `notification` messages properly is a real bug and one I am working on this week.

However from testing I can report that the `data` messages in the above format _DO still work with Fuse.PushNotifications_ even if the app is in the background or is closed.

### Where we are going

Naturally the `notification` message bug needs to be fixed (and will be). I also want to move away from our suboptimal notification layout and use something more appropriate. This is a breaking API change though so our release guidelines require us to deprecate the old stuff for a period of time first.

The question of `data` -v- `notification` messages may remain. By using `data` messages, we are able to do things that are not in the Firebase specification but that our customers have specifically asked for. One example of this is support for [largeIcon](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setLargeIcon(android.graphics.Bitmap)) in notifications, which is something Firebase [do not yet support](https://github.com/firebase/quickstart-android/issues/113#issuecomment-258269513)

### Comments

Please shout below ! Note that we at Fuse won’t be able to take the ‘minimal viable product’ on this library as we have customers using specific features today, however we will get something that works great with how Firebase works, provides a sensible cross-plat behaviour and gives folks time to migrate.

I hope this clears up a little, I’m happy to expand on any part.

---

<div class="post-metadata">

**Author:** ![Simo\_Santavirta](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/simo_santavirta/32/175_2.png) [@Simo\_Santavirta](https://forums.fusetools.com/u/Simo_Santavirta)\
**Post date:** [March 30, 2017, 7:18am UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/17 "2017-03-30T07:18:08Z")

</div>

Thanks a lot. This clears up everything. Got it working now!

---

<div class="post-metadata">

**Author:** ![Joshua\_Clag](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Joshua\_Clag](https://forums.fusetools.com/u/Joshua_Clag)\
**Post date:** [October 20, 2017, 6:10pm UTC](https://forums.fusetools.com/t/push-notificacions-with-google-firebase-notifications/2910/18 "2017-10-20T18:10:15Z")

</div>

The best web notification for me is [https://zetpush.com/](https://zetpush.com/). You can add up to two call-to-action buttons to your web push notifications.
