Skip to content

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

[RN] Add AppInfo module

Saúl Ibarra Corretgé3fdffa749744
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/AppInfoModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/AppInfoModule.java
new file mode 100644
index 0000000000..951430bf2f
--- /dev/null
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/AppInfoModule.java
@@ -0,0 +1,56 @@
+package org.jitsi.meet.sdk;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
+
+import java.util.HashMap;
+import java.util.Map;
+
+class AppInfoModule extends ReactContextBaseJavaModule {
+ /**
+ * React Native module name.
+ */
+ private static final String MODULE_NAME = "AppInfo";
+
+ public AppInfoModule(ReactApplicationContext reactContext) {
+ super(reactContext);
+ }
+
+ /**
+ * Gets a mapping with the constants this module is exporting.
+ *
+ * @return a {@link Map} mapping the constants to be exported with their
+ * values.
+ */
+ @Override
+ public Map<String, Object> getConstants() {
+ Map<String, Object> constants = new HashMap<>();
+ Context context = getReactApplicationContext();
+ PackageManager pm = context.getPackageManager();
+ ApplicationInfo appInfo;
+ PackageInfo packageInfo;
+
+ try {
+ appInfo = pm.getApplicationInfo(context.getPackageName(), 0);
+ packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ constants.put("name", "");
+ constants.put("version", "");
+ return constants;
+ }
+
+ constants.put("name", pm.getApplicationLabel(appInfo));
+ constants.put("version", packageInfo.versionName);
+ return constants;
+ }
+
+ @Override
+ public String getName() {
+ return MODULE_NAME;
+ }
+}
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
index 5a80f9900d..0a25f929b6 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
@@ -61,6 +61,7 @@ public class JitsiMeetView extends FrameLayout {
ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(
new AndroidSettingsModule(reactContext),
+ new AppInfoModule(reactContext),
new AudioModeModule(reactContext),
new ExternalAPIModule(reactContext),
new ProximityModule(reactContext)
diff --git a/ios/sdk/sdk.xcodeproj/project.pbxproj b/ios/sdk/sdk.xcodeproj/project.pbxproj
index 05dc1d40f8..5263da2248 100644
--- a/ios/sdk/sdk.xcodeproj/project.pbxproj
+++ b/ios/sdk/sdk.xcodeproj/project.pbxproj
@@ -14,6 +14,7 @@
0B93EF7E1EC9DDCD0030D24D /* RCTBridgeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */; };
0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */; };
0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */; };
+ 0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BB9AD7C1F60356D001C08DB /* AppInfo.m */; };
0BCA495F1EC4B6C600B793EE /* AudioMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BCA495C1EC4B6C600B793EE /* AudioMode.m */; };
0BCA49601EC4B6C600B793EE /* POSIX.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BCA495D1EC4B6C600B793EE /* POSIX.m */; };
0BCA49611EC4B6C600B793EE /* Proximity.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BCA495E1EC4B6C600B793EE /* Proximity.m */; };
@@ -31,6 +32,7 @@
0B93EF7C1EC9DDCD0030D24D /* RCTBridgeWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTBridgeWrapper.h; sourceTree = "<group>"; };
0B93EF7D1EC9DDCD0030D24D /* RCTBridgeWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTBridgeWrapper.m; sourceTree = "<group>"; };
0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExternalAPI.m; sourceTree = "<group>"; };
+ 0BB9AD7C1F60356D001C08DB /* AppInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppInfo.m; sourceTree = "<group>"; };
0BCA495C1EC4B6C600B793EE /* AudioMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioMode.m; sourceTree = "<group>"; };
0BCA495D1EC4B6C600B793EE /* POSIX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = POSIX.m; sourceTree = "<group>"; };
0BCA495E1EC4B6C600B793EE /* Proximity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Proximity.m; sourceTree = "<group>"; };
@@ -87,6 +89,7 @@
isa = PBXGroup;
children = (
0BCA495C1EC4B6C600B793EE /* AudioMode.m */,
+ 0BB9AD7C1F60356D001C08DB /* AppInfo.m */,
0BA13D301EE83FF8007BEF7F /* ExternalAPI.m */,
0BD906E91EC0C00300C8C18E /* Info.plist */,
0BD906E81EC0C00300C8C18E /* JitsiMeet.h */,
@@ -253,6 +256,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */,
0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */,
0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */,
0BCA49601EC4B6C600B793EE /* POSIX.m in Sources */,
diff --git a/ios/sdk/src/AppInfo.m b/ios/sdk/src/AppInfo.m
new file mode 100644
index 0000000000..ba356bdf54
--- /dev/null
+++ b/ios/sdk/src/AppInfo.m
@@ -0,0 +1,42 @@
+/*
+ * Copyright @ 2017-present Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "RCTBridgeModule.h"
+#import "RCTLog.h"
+
+#import <AVFoundation/AVFoundation.h>
+
+@interface AppInfo : NSObject<RCTBridgeModule>
+@end
+
+@implementation AppInfo
+
+RCT_EXPORT_MODULE();
+
+- (NSDictionary *)constantsToExport {
+ NSString *name = [[[NSBundle mainBundle]infoDictionary]objectForKey :@"CFBundleDisplayName"];
+ NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
+ if (version == nil) {
+ version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
+ if (version == nil) {
+ version = @"";
+ }
+ }
+
+ return @{ @"name" : name, @"version" : version };
+};
+
+@end