Fix bug where `widgetCenterSupported` is false whenever the platform version cannot be cast to a number, i.e. `14.4.2`.
26 lines
720 B
JavaScript
26 lines
720 B
JavaScript
import { NativeModules, Platform } from 'react-native';
|
|
|
|
const { RNWidgetCenter } = NativeModules;
|
|
|
|
export default class WidgetCenter {
|
|
static widgetCenterSupported = Platform.OS === 'ios' && Platform.Version.split('.')[0] >= 14;
|
|
|
|
static reloadTimelines = kind => {
|
|
if (WidgetCenter.widgetCenterSupported) {
|
|
RNWidgetCenter.reloadTimelines(kind)
|
|
}
|
|
}
|
|
|
|
static reloadAllTimelines = () => {
|
|
if (WidgetCenter.widgetCenterSupported) {
|
|
RNWidgetCenter.reloadAllTimelines()
|
|
}
|
|
}
|
|
|
|
static getCurrentConfigurations = () => {
|
|
if (WidgetCenter.widgetCenterSupported) {
|
|
return RNWidgetCenter.getCurrentConfigurations()
|
|
}
|
|
}
|
|
}
|