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";
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
}]);
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:
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 }]);
});`