sAleksovski / react-native-android-widget

Build Android Widgets with React Native
https://sAleksovski.github.io/react-native-android-widget/
MIT License
546 stars 22 forks source link

Re-render widget from WebSocket message #88

Closed juliengbt closed 1 month ago

juliengbt commented 1 month ago

Hey!

First of all I want to that the library is very cool, easy to set up and use. I have a question though, would it be possible to open a WebSocket connection while the app is closed, and update the widget when a message is received from that websocket connection ?

EDIT: After some research, it seems having a websocket connection opened while the app is closed isn't possible. I will have to use push notifications, listen to new notification and then update the widget from there. Would that be possible ?

sAleksovski commented 1 month ago

Sure, it's possible if the push notification is handled in javascript.

Push notifications are not something that is handled in this library directly, you will have to use something else, and call requestWidgetUpdate in the push notification handler.

See https://saleksovski.github.io/react-native-android-widget/docs/update-widget#requestwidgetupdate