diff --git a/index.js b/index.js index e8e1b73a..f68eb0d2 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,22 @@ 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 && + 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 {