Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Add ability to detect calendar permission description in the plist file (iOS)

zbettenbuk56d8210e35d4
diff --git a/ios/sdk/src/AppInfo.m b/ios/sdk/src/AppInfo.m
index 61fc897b9d..6f24fc80cd 100644
--- a/ios/sdk/src/AppInfo.m
+++ b/ios/sdk/src/AppInfo.m
@@ -29,8 +29,13 @@ RCT_EXPORT_MODULE();
- (NSDictionary *)constantsToExport {
NSDictionary<NSString *, id> *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 a83a8fc7b3..cbe3ede676 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 5c9c3c7f45..2a5cd50f0a 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.