2018-04-16 16:39:26 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { NativeModules } from 'react-native';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the calendar feature is enabled by the
|
|
|
|
* app.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
export const CALENDAR_ENABLED = _isCalendarEnabled();
|
|
|
|
|
2018-06-28 09:09:25 +00:00
|
|
|
/**
|
|
|
|
* The default state of the calendar.
|
|
|
|
*
|
|
|
|
* NOTE: This is defined here, to be reusable by functions.js as well (see file
|
|
|
|
* for details).
|
|
|
|
*/
|
|
|
|
export const DEFAULT_STATE = {
|
|
|
|
authorization: undefined,
|
|
|
|
events: []
|
|
|
|
};
|
|
|
|
|
2018-04-16 16:39:26 +00:00
|
|
|
/**
|
|
|
|
* Determines whether the calendar feature is enabled by the app. For
|
|
|
|
* example, Apple through its App Store requires
|
|
|
|
* {@code NSCalendarsUsageDescription} in the app's Info.plist or App Store
|
|
|
|
* rejects the app.
|
|
|
|
*
|
|
|
|
* @returns {boolean} If the app has enabled the calendar feature, {@code true};
|
|
|
|
* otherwise, {@code false}.
|
|
|
|
*/
|
|
|
|
function _isCalendarEnabled() {
|
|
|
|
const { calendarEnabled } = NativeModules.AppInfo;
|
|
|
|
|
|
|
|
return typeof calendarEnabled === 'undefined' ? true : calendarEnabled;
|
|
|
|
}
|