Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Notification won't fire if app is closed #182

Open
emperorjm opened this issue Feb 13, 2020 · 1 comment
Open

Notification won't fire if app is closed #182

emperorjm opened this issue Feb 13, 2020 · 1 comment

Comments

@emperorjm
Copy link

emperorjm commented Feb 13, 2020

I am using the https://market.nativescript.org/plugins/nativescript-laravel-echo plugin to receive broadcasts from my WebSocket server and while the app is loaded I am able to receive the broadcast and trigger the notification which works. This works whether the app is loaded in the foreground or background.

Once I close the app it's not able to receive the broadcast and generate the notification. I am looking at the firebase solution which generates a token which would allow for this I believe but this solution is a lot cleaner and way lot easier to use so I am wondering if this plugin can accommodate my use case.

Setup:

  • Nativescript Vue (2.4.0)
  • Vue (2.6.10)
  • Android 10

Code:

`import { TnsEcho } from 'nativescript-laravel-echo';
import { LocalNotifications } from "nativescript-local-notifications";

const options = {
key: 'oyraytsytgd',
wsHost: '178.65.34.27',
wsPort: 6001,
disableStats: true,
broadcaster: 'pusher', // socket.io, pusher
};

let Echo = new TnsEcho(options);
Echo.channel('payment').listen('Payment', e => {
console.log(e);
LocalNotifications.schedule([{
title: 'You have a new Payment Request',
body: 'A user is requesting a payment,
bigTextStyle: false,
forceShowWhenInForeground: true,
at: new Date(new Date().getTime() + (5 * 1000)), // 5 seconds from now
}]);

LocalNotifications.addOnMessageReceivedCallback(notificationData => {
    this.$navigateTo(Payment, { props: { id: e.id } });
});

});`

@sikemullivan
Copy link

When the application is closed, your websocket is also closed. I would imagine you need to switch to a push notification.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants