Fuse Community

Push Module - receivedMessage

In the last release of FuseLibs and uno (1.13) when I click on a push notification the receivedMessage don’t trigger when the app is open. This worked in previous version but now its imposible to excute some action when I click in a notification.

I test it on Android…

If 1.13 included the AndroidX support, then you would need to upgrade all the dependencies to use AndroidX libraries like so: https://github.com/fuse-open/fuselibs/pull/1318/files

AndroidX PRs:



But @aeq this solve the onMessageReceived? My push work fine but the only problem, I think in iOS also happen, is when I click a push notification with the app closed or in background and the receivedMessage don’t trigger.

I really need to open the notification section in many apps when I click the notification when the app is closed or in background… I have many apps with this error and this worked fine in previous versions…

Which push notification module are you using?

I’m using https://fuseopen.com/docs/fuse/pushnotifications/push.html with uno 1.13.2 and fuselibs 1.13.0

Ok, I’m gonna do tests with latest everything…

I just tested for iOS and can confirm:

  • registration succeeded
  • payload was received via receivedMessage
    • when app is open
    • when app is closed
    • when app is “minimised” or in background

I just tested for Android and can confirm:

  • registration succeeded
  • payload was received via receivedMessage
    • when app is open
    • when app is closed
    • when app is “minimised” or in background

Latest fuselibs now has AndroidX Support merged:

There is still an android push notification update PR:

Tested now in a separarate app with Uno Canary and the Fuselibs you send me. On iOS work perfect but on Android dont trigger receivedMessage when the app is in background or closed and I click the notification from the topbar.

Tested on a Samsung Note 10+, Huawei p30 pro with Android 9, Samsung S4 with Android 5.0.1 and doesn’t work!

I tested on Samsung Galaxy Note10+ and Samsung Galaxy Tab S4, both worked with Android 9.

I updated the PR to include the latest master but I don’t think that’s the issue: https://github.com/fuse-open/fuselibs/pull/1318

Tested with master fuselibs and uno repos + PR: https://github.com/fuse-open/fuselibs/pull/1318

I try all and doesn’t work :dizzy_face:
Now I try with:

"dependencies": {
    "@fuse-open/fuselibs": "^1.14.0-canary.0",
    "@fuse-open/uno": "^1.14.0-canary.1",
    "android-build-tools": "^1.3.0-canary.0"
  }

And don’t work

Might have something to do with this : https://onesignal.com/blog/manufacturers-interfere-with-reliable-notifications/

I follow the instructions but the same problem

I receive the push perfect on my device. If I have the app open and a notification arrives the receivedMessage function execute fine. But if my app is in background, the push arrives but if I click on it, the app opens but the receivedMessage don’t trigger…

Here is a video to demostrate my problem: video.zip (4.1 MB)

My MainView:

<App>
	<JavaScript>
		var Push = require("FuseJS/Push");
		var vibration = require('FuseJS/Vibration');
		var Observable = require("FuseJS/Observable");


		var Message = Observable("-");

		Push.on("registrationSucceeded", function(regID) {
			console.log("registrationSucceeded_____________________________________________________________________________________");
		    console.log(regID)
		});

		Push.on("error", function(reason) {
			console.log("Error_____________________________________________________________________________________");
			console.log(reason);
		});

		Push.on("receivedMessage", function(payload) {
			console.log("receivedMessage_____________________________________________________________________________________");

			Message.value = "Received!!!!";

			setTimeout(function() {
				Message.value = "-";
			}, 3000);

			vibration.vibrate(1);
		});

		module.exports = {
			Message: Message,
		};
	</JavaScript>

	<Text Value="{Message}" TextAlignment="Center" Color="#000" FontSize="50" Alignment="VerticalCenter" />
</App>

My .unoproj:

{
  "Title": "test",
  "RootNamespace":"test",
  "Version": "3.23",
  "VersionCount": 323,
  "Mobile": {
    "Orientations": "Portrait"
  },
  "Packages": [
    "Fuse",
    "FuseJS",
    "Fuse.PushNotifications",
    "Fuse.Vibration"
  ],
  "Android": {
    "WindowIsTranslucent" : false,
    "UsesCleartextTraffic": true,
    "GooglePlay": {
          "SenderID": "xxxxxx"
    },
    "Package": "xxxxx"
  },
  "Includes": [
    "*"
  ]
}

Solved. For some strange reason don’t work when I send the push with the notification and data in the same message like:

fetch('https://fcm.googleapis.com/fcm/send', {
        'method': 'POST',
        'headers': {
          'Authorization': 'key=xxxx',
          'Content-Type': 'application/json'
        },
        'body': JSON.stringify({
          'notification': notification,
          'data': payload,
          "priority":"high",
          "content_available": true,
          'to': to
        })
      }).then(function(response) {
      }).catch(function(error) {
      });

But if I send one with the notification and other with the data work perfect!

fetch('https://fcm.googleapis.com/fcm/send', {
    'method': 'POST',
    'headers': {
      'Authorization': 'key=xxxx',
      'Content-Type': 'application/json'
    },
    'body': JSON.stringify({
      'data': payload,
      "priority":"high",
      "content_available": true,
      'to': to
    })
  }).then(function(response) {
  }).catch(function(error) {
  });

  fetch('https://fcm.googleapis.com/fcm/send', {
    'method': 'POST',
    'headers': {
      'Authorization': 'key=xxxx',
      'Content-Type': 'application/json'
    },
    'body': JSON.stringify({
      'notification': notification,
      "priority":"high",
      "content_available": true,
      'to': to
    })
  }).then(function(response) {
  }).catch(function(error) {
  });

I think it has to do with the format around “data”, this is how I sent mine in a test that works:

fetch('https://fcm.googleapis.com/fcm/send', {
    method: 'post',
    headers: {
        'Authorization': 'key=' + API_ACCESS_KEY,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        registration_ids: [regID.value],
        data: {
            notification: {
                alert: {
                    title: 'Well would ya look at that!',
                    body: 'Hello there'
                }
            },
            payload: 'anything you like'
        }
    })
}).then(function(response) {
    console.log(JSON.stringify(response));
}, function(error) {
    console.log(error);
});