riot-embedded icon indicating copy to clipboard operation
riot-embedded copied to clipboard

setting up push notifications

Open lemonspb opened this issue 5 years ago • 4 comments
trafficstars

Hi, is there a simple way to set up push notification through your app?

lemonspb avatar Aug 25 '20 14:08 lemonspb

Hello. Are you talking about desktop notifications?

arnav-t avatar Aug 25 '20 16:08 arnav-t

yes, the question is rather what event should I listen to for push

lemonspb avatar Aug 25 '20 18:08 lemonspb

There aren't any globally visible events you can listen to yet. I can add something in the future to emit events for notifications.

arnav-t avatar Aug 26 '20 17:08 arnav-t

here i found a pretty simple solution

sendingPushNotifications = (event) => {
          
        if (event.event.type === "m.room.message" 
        && event.event.sender !== this.props.userId 
        && document.hidden) {
            addNotification({
                title: `сообщение от ${event.sender.rawDisplayName}`,
                message: `${event.event.content.body}`,
                theme: 'darkblue',
                native: true
            });
        }
    };

lemonspb avatar Sep 17 '20 13:09 lemonspb