diff --git a/ios/sdk/src/AppInfo.m b/ios/sdk/src/AppInfo.m index 61fc897b9..6f24fc80c 100644 --- a/ios/sdk/src/AppInfo.m +++ b/ios/sdk/src/AppInfo.m @@ -29,8 +29,13 @@ RCT_EXPORT_MODULE(); - (NSDictionary *)constantsToExport { NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; + + // calendarEnabled + BOOL calendarEnabled + = infoDictionary[@"NSCalendarsUsageDescription"] != nil; + + // name NSString *name = infoDictionary[@"CFBundleDisplayName"]; - NSString *version = infoDictionary[@"CFBundleShortVersionString"]; if (name == nil) { name = infoDictionary[@"CFBundleName"]; @@ -38,6 +43,13 @@ RCT_EXPORT_MODULE(); name = @""; } } + + // sdkBundlePath + NSString *sdkBundlePath = [[NSBundle bundleForClass:self.class] bundlePath]; + + // version + NSString *version = infoDictionary[@"CFBundleShortVersionString"]; + if (version == nil) { version = infoDictionary[@"CFBundleVersion"]; if (version == nil) { @@ -45,9 +57,8 @@ RCT_EXPORT_MODULE(); } } - NSString *sdkBundlePath = [[NSBundle bundleForClass:self.class] bundlePath]; - return @{ + @"calendarEnabled": [NSNumber numberWithBool:calendarEnabled], @"name": name, @"sdkBundlePath": sdkBundlePath, @"version": version diff --git a/react/features/app/functions.native.js b/react/features/app/functions.native.js index a83a8fc7b..cbe3ede67 100644 --- a/react/features/app/functions.native.js +++ b/react/features/app/functions.native.js @@ -1,4 +1,5 @@ -/* @flow */ +// @flow + import { NativeModules } from 'react-native'; export * from './getRouteToRender'; diff --git a/react/features/calendar-sync/middleware.js b/react/features/calendar-sync/middleware.js index 5c9c3c7f4..2a5cd50f0 100644 --- a/react/features/calendar-sync/middleware.js +++ b/react/features/calendar-sync/middleware.js @@ -1,5 +1,6 @@ // @flow +import { NativeModules } from 'react-native'; import RNCalendarEvents from 'react-native-calendar-events'; import { APP_WILL_MOUNT } from '../app'; @@ -123,6 +124,11 @@ function _fetchCalendarEntries( { dispatch, getState }, maybePromptForPermission, forcePermission) { + if (!_isCalendarEnabled()) { + // The calendar feature is not enabled. + return; + } + const state = getState()['features/calendar-sync']; const promptForPermission = (maybePromptForPermission && !state.authorization) @@ -194,6 +200,20 @@ function _getURLFromEvent(event, knownDomains) { return null; } +/** + * Determines whether the calendar feature is enabled by the app. For + * example, Apple through its App Store requires 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}. + */ +export function _isCalendarEnabled() { + const { calendarEnabled } = NativeModules.AppInfo; + + return typeof calendarEnabled === 'undefined' ? true : calendarEnabled; +} + /** * Retreives the domain name of a room upon join and stores it in the known * domain list, if not present yet.