From 25a0beffe8a22b3d83098eb9978c87a9b900e65e Mon Sep 17 00:00:00 2001 From: Rishi Balakrishnan Date: Thu, 30 Jul 2026 12:32:26 -0400 Subject: [PATCH] Fix iOS share sheet (#141) --- .../ShareViewController.swift | 16 ++++++++++++++-- .../withExtensionInfoPlist.js | 9 +++++++-- plugins/shareExtension/withExtensionInfoPlist.js | 8 +++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/Share-with-Blacksky/ShareViewController.swift b/modules/Share-with-Blacksky/ShareViewController.swift index e2839a921..7cbde3620 100644 --- a/modules/Share-with-Blacksky/ShareViewController.swift +++ b/modules/Share-with-Blacksky/ShareViewController.swift @@ -12,8 +12,20 @@ enum URLType: String, CaseIterable { class ShareViewController: UIViewController { // This allows other forks to use this extension while also changing their - // scheme. - let appScheme = Bundle.main.object(forInfoDictionaryKey: "MainAppScheme") as? String ?? "bluesky" + // scheme. `MainAppScheme` may be a single String or an array of schemes + // (forks that register more than one URL scheme); accept both and use the + // first entry. Falling back to a hardcoded scheme here would silently open a + // different installed app, so handle the array case explicitly. + let appScheme: String = { + let value = Bundle.main.object(forInfoDictionaryKey: "MainAppScheme") + if let scheme = value as? String { + return scheme + } + if let schemes = value as? [String], let first = schemes.first { + return first + } + return "blacksky" + }() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) diff --git a/plugins/notificationsExtension/withExtensionInfoPlist.js b/plugins/notificationsExtension/withExtensionInfoPlist.js index 8de8c9910..b4fe10e5c 100644 --- a/plugins/notificationsExtension/withExtensionInfoPlist.js +++ b/plugins/notificationsExtension/withExtensionInfoPlist.js @@ -19,9 +19,14 @@ const withExtensionInfoPlist = (config, {extensionName}) => { const extPlist = plist.default.parse(fs.readFileSync(plistPath).toString()) - extPlist.MainAppScheme = config.scheme + // `config.scheme` may be an array when the app registers multiple URL + // schemes; coerce to a single scheme so consumers reading it as a String + // don't silently fall back to another app's scheme. + extPlist.MainAppScheme = Array.isArray(config.scheme) + ? config.scheme[0] + : config.scheme extPlist.CFBundleName = '$(PRODUCT_NAME)' - extPlist.CFBundleDisplayName = 'Bluesky Notifications' + extPlist.CFBundleDisplayName = 'Blacksky Notifications' extPlist.CFBundleIdentifier = '$(PRODUCT_BUNDLE_IDENTIFIER)' extPlist.CFBundleVersion = '$(CURRENT_PROJECT_VERSION)' extPlist.CFBundleExecutable = '$(EXECUTABLE_NAME)' diff --git a/plugins/shareExtension/withExtensionInfoPlist.js b/plugins/shareExtension/withExtensionInfoPlist.js index 4e1c299b3..460dbbcb9 100644 --- a/plugins/shareExtension/withExtensionInfoPlist.js +++ b/plugins/shareExtension/withExtensionInfoPlist.js @@ -19,7 +19,13 @@ const withExtensionInfoPlist = (config, {extensionName}) => { const extPlist = plist.default.parse(fs.readFileSync(plistPath).toString()) - extPlist.MainAppScheme = config.scheme + // `config.scheme` may be an array when the app registers multiple URL + // schemes. The extension reads a single scheme, so coerce to the first one + // (writing the array would break the String cast and fall back to opening + // another app, e.g. Bluesky). + extPlist.MainAppScheme = Array.isArray(config.scheme) + ? config.scheme[0] + : config.scheme extPlist.CFBundleName = '$(PRODUCT_NAME)' extPlist.CFBundleDisplayName = 'Extension' extPlist.CFBundleIdentifier = '$(PRODUCT_BUNDLE_IDENTIFIER)' -- knotmirror 0.0.1