# Push Notifications doesn't work on fuse preview

**URL:** <https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637>\
**Category:** How-to Discussions\
**Created:** [February 9, 2019, 9:38pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637 "2019-02-09T21:38:19Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 9, 2019, 9:38pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/1 "2019-02-09T21:38:19Z")

</div>

When trying to config Push Notifications on my app I get no console.log message from `registrationSucceeded` or `error`, I’m running on view, not on real android device or emulator.

Here is my code  
 ![Capture](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/fusetools1/original/1X/804d8d2e69d34ae1f8afd55a0b7413ab25c71664.png)

Here is uno file ![Capturess](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/fusetools1/original/1X/5267d4844db6ec2d49c663e04092b5876c83b1ab.png)

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 11, 2019, 5:00am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/3 "2019-02-11T05:00:07Z")

</div>

Yes, that is because you need a real device to test push notifications.

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 11, 2019, 5:51am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/4 "2019-02-11T05:51:57Z")

</div>

Thank you, but console.log doesn’t print anything ?

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 11, 2019, 6:28am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/5 "2019-02-11T06:28:51Z")

</div>

Yeah, on Android Oreo+, the console.logs are not working on terminal for an export, I think it works for an exported preview but I haven’t tested push that way to say, its something that needs to be looked into but you can use the interface to see your data in the meantime, here’s my basic test app UX you can use:

```auto
<App Background="#18f">
	<JavaScript>
    var Push = require("FuseJS/Push");
		var Observable = require("FuseJS/Observable");

		var status = Observable("-");
		var message = Observable("-no message yet-");
		
		Push.on("registrationSucceeded", function(regID) {
		    console.log("Reg Succeeded: " + regID);
		    status.value = "Success: " + regID;
		});
		
		Push.on("error", function(reason) {
		// Push.onRegistrationFailed = function(reason) {
		    console.log ("Reg Failed: " + reason);
		    status.value = "Failed: " + reason;
		});

		Push.on("receivedMessage", function(payload, fromNotificationBar) {
		// Push.onReceivedMessage = function(payload, fromNotificationBar) {
		    console.log("Recieved Push Notification: " + payload);
		    console.log("fromNotificationBar="+fromNotificationBar);
		    payloadData = JSON.parse(payload);
		    message.value = payload;
		    console.log('PAYLOAD');
		    console.log(payload);
		    console.log('PAYLOADDATA');
		    console.dir(payloadData);
		});

		var clearBadgeNumber = function() {
		    Push.clearBadgeNumber();
		}

		var clearAllNotifications = function() {
		    Push.clearAllNotifications();
		}
		
		console.log('INITIALISING!');

		module.exports = {
		    message: message,
		    status: status,

		    clearBadgeNumber: clearBadgeNumber,
		    clearAllNotifications: clearAllNotifications,
		};
	</JavaScript>

	<DockPanel>
		<StackPanel Dock="Top" Background="#18f">
			<StatusBarBackground/>
			<Fuse.iOS.StatusBarConfig Style="Light"/>
		</StackPanel>

		<ScrollView>
			<StackPanel Width="92%" Padding="20">
				<Text Value="Notifications Test" Alignment="Center" FontSize="25" TextColor="#18f" TextWrapping="Wrap"/>

				<Button Padding="10" Clicked="{clearBadgeNumber}" Text="Clear Badge Number"/>
				<Button Padding="10" Clicked="{clearAllNotifications}" Text="Clear All Notifications"/>

				<Text Alignment="Left" Value="Status"/>
				<Text Alignment="Left" Value="{status}" TextWrapping="Wrap"/>
				<Text Alignment="Left" Value="{message}" TextWrapping="Wrap"/>

				<Rectangle Layer="Background" CornerRadius="9" Color="#fff"/>
			</StackPanel>
		</ScrollView>

		<BottomBarBackground Dock="Bottom" />
	</DockPanel>
</App>

```

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 11, 2019, 6:31am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/6 "2019-02-11T06:31:41Z")

</div>

Btw, the current push notifications that comes with fuse uses the old GCM way of receiving push notifications which will end in April and you won’t be able to receive notifications on newer androids because you need to specify a channel. I’ve got an updated version of push that uses FCM here and has default settings: [https://github.com/fuse-open/fuselibs/pull/1220](https://github.com/fuse-open/fuselibs/pull/1220)

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 12, 2019, 7:14am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/7 "2019-02-12T07:14:24Z")

</div>

I tested on real device and the regID is printed on the text filed but when i send notification from Fire-base the notification doesn’t appear on the device.

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 12, 2019, 7:52am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/8 "2019-02-12T07:52:09Z")

</div>

That will be due to the payload structure sent, here’s the format that needs to be sent at a minimum:

```auto
priority: 'high',
data: {
    notification: {
        alert: {
            title: 'There is something cool to look at',
            body: 'Hello World!'
        }
    },
    payload: 'anything you like'
}

```

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 12, 2019, 7:55am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/9 "2019-02-12T07:55:08Z")

</div>

You can find examples of the other features I added here: [https://github.com/fuse-open/fuselibs/blob/1792c481f3b7b7758a03060910b50978c6d35929/Source/Fuse.PushNotifications/Docs/Guide.md#additional-android-push-notification-features](https://github.com/fuse-open/fuselibs/blob/1792c481f3b7b7758a03060910b50978c6d35929/Source/Fuse.PushNotifications/Docs/Guide.md#additional-android-push-notification-features)

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 12, 2019, 1:16pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/10 "2019-02-12T13:16:42Z")

</div>

Okay thank for that, but i didn’t understand you correctly, i’m sending the notification form Fir-base Console so where this code should be written? in the console i just fill the filed of the message and Fire-base send the message.

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 12, 2019, 1:38pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/11 "2019-02-12T13:38:19Z")

</div>

Yeah, you can’t just use the console as it has its own fixed payload structure, you would need to use your own server, see the [How does it work?](https://firebase.google.com/docs/cloud-messaging) section of Googles firebase cloud messaging, we’re basically talking about the “Trusted Environment”.

I found an easy site/tool for testing: [http://pushtry.com](http://pushtry.com)

If you don’t want to give your credentials, even though they’re dev, then you could use something like a Node.js module to test from your machine: [https://www.npmjs.com/package/fcm-node](https://www.npmjs.com/package/fcm-node)

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 15, 2019, 12:51pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/12 "2019-02-15T12:51:58Z")

</div>

Thank you @aeq okay that is good, the notification worked in the app, but the notification didn’t appeared on device notifications bar. ![image](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/fusetools1/original/1X/c4d6668089e141cbe39cedb00963b99a73359a36.png).  
Screenshot from mobile app

![Screenshot_2019-02-15-16-14-26](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/fusetools1/original/1X/926545ca7916781dee7090cefcff83d2bff52daa.png)

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 15, 2019, 1:04pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/13 "2019-02-15T13:04:50Z")

</div>

That’s cos you have the app open, you gotta minimize or close the app now before sending the push.

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 15, 2019, 1:20pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/14 "2019-02-15T13:20:03Z")

</div>

Okay that is working good, only the notification appear if app is minimized if i closed the app the notification doesn’t appeared!

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 15, 2019, 2:19pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/15 "2019-02-15T14:19:27Z")

</div>

I just ran tests on old and new androids and they’re working…

While the app was closed:

- Did you pull down your notification bar to see if its there?

- Did you tap your power off, to see the notification appear in the lock screen?

How did you check because sound is not on by default for instance, that’s an option you need to set in the payload.

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 15, 2019, 4:27pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/16 "2019-02-15T16:27:16Z")

</div>

> Blockquote Did you pull down your notification bar to see if its there?

Only if the app is minimized

> Did you tap your power off, to see the notification appear in the lock screen?

Yes I did

I did all these stuff, i tried to send notification when the app is minimized and it’s working and showed in the notification bar, but when i close the application the notification doesn’t appear in the notification bar,

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 15, 2019, 4:51pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/17 "2019-02-15T16:51:57Z")

</div>

Oh, I just checked your payload again, you’re missing an outer data attribute like this but if its not this, read further below:

```auto
{
    priority: 'high',
    data: {

        notification: {
            alert: {
                title: "There is something cool to look at",
                body: "Hello World!"
            }
        },
        payload: "anything you like"
        
    }
}

```

It could be that you gotta set the importance level of the notification channel to high importance, the default is set to the “default” value: [https://developer.android.com/guide/topics/ui/notifiers/notifications](https://developer.android.com/guide/topics/ui/notifiers/notifications)

So like this (I added the notificationPriority for you to experiment with too):

```auto
{
    priority: 'high',
    data: {

        notification: {
            alert: {
                title: "There is something cool to look at",
                body: "Hello World!",
                notificationChannelImportance: "high",
                
                notificationPriority: "high",
            }
        },
        payload: "anything you like"
        
    }
}

```

---

<div class="post-metadata">

**Author:** ![ahmed\_salah](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@ahmed\_salah](https://forums.fusetools.com/u/ahmed_salah)\
**Post date:** [February 15, 2019, 5:59pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/18 "2019-02-15T17:59:04Z")

</div>

Still the same problem,

```
         {
	        "to": "Device Key",
	              "priority": "high",
	                "data": {

	"notification": {
		"alert": {
			"title": "There is something cool to look at",
			"body": "Hello World!",
			"notificationChannelImportance": "high",
			"notificationPriority": "high",
			"sound": "default"
		}
	},
	"payload": "anything you like"

}
}

```

Do I need to make my application running in the background? or Push notification work fine even if fuse app not running in the background?

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 15, 2019, 6:18pm UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/19 "2019-02-15T18:18:08Z")

</div>

No you shouldn’t have to do that…

Did you delete the app before between each change or test? As the push notification settings for an app are fixed after the first push (unless programmatically or manually changed).

If you didn’t delete before testing again, then the app can still be in a lower importance or priority, you can confirm this in the apps push notifications settings.

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [February 18, 2019, 6:32am UTC](https://forums.fusetools.com/t/push-notifications-doesnt-work-on-fuse-preview/7637/20 "2019-02-18T06:32:16Z")

</div>

I take it its working for you now?
