I have to Push Notifications to all the users who are using OpenFin for my site. As per OpenFin documentation, they have provided API to send a Desktop Notification on an event like button click. But if the OpenFin App is Idle and we need send notifications then how can I achieve that?
I went through the example on this site provided by OpenFin.
Can anyone help with sample code for push Notification in javascript?
The example provided in the link is outdated as it uses old Openfin API. I suggest you to use latest API for notificationsOpenfin Notification API
fin.Notification.create({
url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Notification.create.html',
timeout: 3000
}).show().then(() => console.log('Notification created')).catch(err => console.log(err));
You will need to install openfin-notificaitons
using npm i openfin-notifications
. Once it is installed, import it and use it like Varun mentioned
import {create} from 'openfin-notifications';
create({
title : 'my-title',
body : 'Any additional content',
category : 'Event',
buttons : [
{
title : 'Accept'
onClick : {
task : 'click-me'
}
}
]
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.