react-native-widget-center/index.js
Brodie 269004c08f Fix platform version checking
Fix bug where `widgetCenterSupported` is false whenever the platform version cannot be cast to a number, i.e. `14.4.2`.
2021-05-31 16:45:22 -07:00

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()
}
}
}