0.3.2 • Published 3 years ago

cordova-plugin-widget-center v0.3.2

Weekly downloads
25
License
MIT
Repository
github
Last release
3 years ago

cordova-plugin-widget-center

This plugin provides access to the WidgetCenter introduced in iOS14. Use it to retrieve information about widgets that extend your Cordova app or reload their timelines (i.e. update dynamic content)

Installation:

cordova plugin add corodova-plugin-widget-center

This plugin was written in Swift and requires Cordova iOS 5.0.0+ or something like cordova-plugin-add-swift-support to properly build.

Usage

For general advice, please refer to Apple's developer information on WidgetCenter and creating widgets in your Xcode project.

The following documentation is adapted to plugin use from the official docs for your convenience:

Getting Configured Widget Information

To get a list of user-configured widgets, use WidgetCenter.getCurrentConfigurations(). The return value contains the following information:

  • The kind string matches the parameter you use when creating the widget's StaticConfiguration or IntentConfiguration.

  • The family property matches one of the options specified in the supportedFamilies property of the widget's configuration.

  • If your widget is based on IntentConfiguration, the configuration property provides the custom intent containing the user-customized values for each individual widget.

The return values are only concenated into a string in this version of the plugin.

WidgetCenter.getCurrentConfigurations(s=>console.log('Success:',s),e=>console.log('Error:',e))

Requesting a Reload of Your Widget's Timeline

Changes in your app's state may affect a widget's timeline. When this happens, you can tell WidgetKit to reload the timeline for either a specific kind of widget or all widgets. For example, your app might register for push notifications based on the widgets the user has configured. When your app receives a push notification that changes the state for one or more of your widgets, requesting a reload of their timelines updates their display.

If you only need to reload a certain kind of widget, you can request a reload for only that kind. For example, in response to a push notification about a change in a game's status, you could request a reload for only the game status widgets:

WidgetCenter.reloadTimelines("com.mygame.gamestatus",s=>console.log('Success:',s),e=>console.log('Error:',e))

To request a reload for all of your widgets:

WidgetCenter.reloadAllTimelines(s=>console.log('Success:',s),e=>console.log('Error:',e))
0.3.2

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago