From a075a4fad6eb9d8f3971b93ae120eb925eff30dc Mon Sep 17 00:00:00 2001 From: Ryan Linton Date: Wed, 23 Aug 2023 10:27:21 -0600 Subject: [PATCH 1/2] add isExtension to ShareMenuReactView --- index.js | 15 ++++++++------- ios/Modules/ShareMenuReactView.swift | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index e8e1b73a..bdd4d798 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import { NativeModules, NativeEventEmitter } from "react-native"; +import { NativeEventEmitter, NativeModules } from "react-native"; const { ShareMenu } = NativeModules; @@ -7,18 +7,19 @@ const EventEmitter = new NativeEventEmitter(ShareMenu); const NEW_SHARE_EVENT_NAME = "NewShareEvent"; export const ShareMenuReactView = { - dismissExtension(error = null) { - NativeModules.ShareMenuReactView.dismissExtension(error); - }, - openApp() { - NativeModules.ShareMenuReactView.openApp(); - }, continueInApp(extraData = null) { NativeModules.ShareMenuReactView.continueInApp(extraData); }, data() { return NativeModules.ShareMenuReactView.data(); }, + dismissExtension(error = null) { + NativeModules.ShareMenuReactView.dismissExtension(error); + }, + isExtension: NativeModules.ShareMenuReactView.isExtension, + openApp() { + NativeModules.ShareMenuReactView.openApp(); + }, }; export default { diff --git a/ios/Modules/ShareMenuReactView.swift b/ios/Modules/ShareMenuReactView.swift index e290ccec..f32effcd 100644 --- a/ios/Modules/ShareMenuReactView.swift +++ b/ios/Modules/ShareMenuReactView.swift @@ -27,6 +27,11 @@ public class ShareMenuReactView: NSObject { ShareMenuReactView.viewDelegate = nil } + @objc + func constantsToExport() -> [String: Any]! { + return ["isExtension": ShareMenuReactView.viewDelegate?.loadExtensionContext() != nil] + } + @objc(dismissExtension:) func dismissExtension(_ error: String?) { guard let extensionContext = ShareMenuReactView.viewDelegate?.loadExtensionContext() else { From d5a7a3132f68df91b0e7f7144c6644df31be06b2 Mon Sep 17 00:00:00 2001 From: Ryan Linton Date: Wed, 13 Sep 2023 11:19:40 -0600 Subject: [PATCH 2/2] fix for Android --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index bdd4d798..f68eb0d2 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,10 @@ export const ShareMenuReactView = { dismissExtension(error = null) { NativeModules.ShareMenuReactView.dismissExtension(error); }, - isExtension: NativeModules.ShareMenuReactView.isExtension, + isExtension: !!( + NativeModules.ShareMenuReactView && + NativeModules.ShareMenuReactView.isExtension + ), openApp() { NativeModules.ShareMenuReactView.openApp(); },