1.0.6 • Published 6 years ago

react-native-widget-manager v1.0.6

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

react-native-widget-manager

Provide an JS API to force native Android widgets reload and getting their ids

Installation

Android

npm i react-native-widget-manager --save
react-native link react-native-widget-manager

Change your MainAplication.java from

new WidgetManagerPackage()

to

new WidgetManagerPackage(Widget.class, null)

if you want to use AppWidgetManager.EXTRA_APPWIDGET_IDS field for widget IDs, or

new WidgetManagerPackage(Widget.class, "mySpecificIDsField")

if you want to use your own field (recommended)

where Widget is your widget provider java class (you should have Widget.java in your source code)

https://developer.android.com/guide/topics/appwidgets/index.html

API

Works for Android only but safe to execute on iOS.

reloadWidgets(delay)

Reload all widgets that were instantiated from your Widget.java (Do nothing on iOS)

  • There is a bug in React/Android/Headless JS that you can't use setTimeout inside a background task, so you may need a way to reload your widgets after JS -> Native synchronization. For example after AsyncStorage save; For this case you can use this delay. If you don't need any sync keep it 0 or don't define it.

getWidgetIds

Return promise that will be fulfilled with array of ids. (Return empty array on iOS)

1.0.6

6 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago