From 320137e6d683d8b6192af3b461c57e74e6c83969 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Fri, 12 Jul 2024 14:59:27 +0100 Subject: [PATCH 1/9] feat(react-native-google-cast): add startDiscoveryAfterFirstTapOnCastButton and physicalVolumeButtonsWillControlDeviceVolume options to IOS --- .../src/withGoogleCast.ts | 15 +++++++- .../src/withIosGoogleCast.ts | 36 ++++++++++++++----- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/packages/react-native-google-cast/src/withGoogleCast.ts b/packages/react-native-google-cast/src/withGoogleCast.ts index ce2ba06d..37cae21b 100644 --- a/packages/react-native-google-cast/src/withGoogleCast.ts +++ b/packages/react-native-google-cast/src/withGoogleCast.ts @@ -19,6 +19,16 @@ const withGoogleCast: ConfigPlugin< * ?? */ androidReceiverAppId?: string; + + /** + * @default true + */ + startDiscoveryAfterFirstTapOnCastButton?: boolean; + + /** + * @default false + */ + physicalVolumeButtonsWillControlDeviceVolume?: boolean; } | void > = (config, _props) => { const props = _props || {}; @@ -26,7 +36,10 @@ const withGoogleCast: ConfigPlugin< config = withIosGoogleCast(config, { receiverAppId: props.iosReceiverAppId, // disableDiscoveryAutostart?: boolean; - // startDiscoveryAfterFirstTapOnCastButton?: boolean; + startDiscoveryAfterFirstTapOnCastButton: + props.startDiscoveryAfterFirstTapOnCastButton, + physicalVolumeButtonsWillControlDeviceVolume: + props.physicalVolumeButtonsWillControlDeviceVolume, }); config = withAndroidGoogleCast(config, { diff --git a/packages/react-native-google-cast/src/withIosGoogleCast.ts b/packages/react-native-google-cast/src/withIosGoogleCast.ts index 49b461d1..32a71e5d 100644 --- a/packages/react-native-google-cast/src/withIosGoogleCast.ts +++ b/packages/react-native-google-cast/src/withIosGoogleCast.ts @@ -46,7 +46,7 @@ const withIosLocalNetworkPermissions: ConfigPlugin<{ // Add required values config.modResults.NSBonjourServices.push( "_googlecast._tcp", - `_${receiverAppId}._googlecast._tcp`, + `_${receiverAppId}._googlecast._tcp` ); // Remove duplicates @@ -81,16 +81,16 @@ const withIosAppDelegateLoaded: ConfigPlugin = (config, props) => { return withAppDelegate(config, (config) => { if (!["objc", "objcpp"].includes(config.modResults.language)) { throw new Error( - "react-native-google-cast config plugin does not support AppDelegate' that aren't Objective-C(++) yet.", + "react-native-google-cast config plugin does not support AppDelegate' that aren't Objective-C(++) yet." ); } config.modResults.contents = addGoogleCastAppDelegateDidFinishLaunchingWithOptions( config.modResults.contents, - props, + props ).contents; config.modResults.contents = addGoogleCastAppDelegateImport( - config.modResults.contents, + config.modResults.contents ).contents; return config; @@ -102,6 +102,16 @@ export const withIosGoogleCast: ConfigPlugin<{ * @default 'CC1AD845' */ receiverAppId?: string; + + /** + * @default true + */ + startDiscoveryAfterFirstTapOnCastButton?: boolean; + + /** + * @default false + */ + physicalVolumeButtonsWillControlDeviceVolume?: boolean; }> = (config, props) => { config = withIosWifiEntitlements(config); config = withIosLocalNetworkPermissions(config, { @@ -110,7 +120,10 @@ export const withIosGoogleCast: ConfigPlugin<{ config = withIosAppDelegateLoaded(config, { receiverAppId: props.receiverAppId, // disableDiscoveryAutostart?: boolean; - // startDiscoveryAfterFirstTapOnCastButton?: boolean; + startDiscoveryAfterFirstTapOnCastButton: + props.startDiscoveryAfterFirstTapOnCastButton, + physicalVolumeButtonsWillControlDeviceVolume: + props.physicalVolumeButtonsWillControlDeviceVolume, }); // TODO @@ -127,6 +140,7 @@ type IosProps = { receiverAppId?: string | null; disableDiscoveryAutostart?: boolean; startDiscoveryAfterFirstTapOnCastButton?: boolean; + physicalVolumeButtonsWillControlDeviceVolume?: boolean; }; export function addGoogleCastAppDelegateDidFinishLaunchingWithOptions( @@ -135,7 +149,8 @@ export function addGoogleCastAppDelegateDidFinishLaunchingWithOptions( receiverAppId = null, disableDiscoveryAutostart = false, startDiscoveryAfterFirstTapOnCastButton = true, - }: IosProps = {}, + physicalVolumeButtonsWillControlDeviceVolume = false, + }: IosProps = {} ) { let newSrc = []; newSrc.push( @@ -152,10 +167,13 @@ export function addGoogleCastAppDelegateDidFinishLaunchingWithOptions( // TODO: Same as above, read statically // ` options.disableDiscoveryAutostart = ${String(!!disableDiscoveryAutostart)};`, ` options.startDiscoveryAfterFirstTapOnCastButton = ${String( - !!startDiscoveryAfterFirstTapOnCastButton, + !!startDiscoveryAfterFirstTapOnCastButton + )};`, + ` options.physicalVolumeButtonsWillControlDeviceVolume = ${String( + !!physicalVolumeButtonsWillControlDeviceVolume )};`, " [GCKCastContext setSharedInstanceWithOptions:options];", - "#endif", + "#endif" ); newSrc = newSrc.filter(Boolean); @@ -175,7 +193,7 @@ function addGoogleCastAppDelegateImport(src: string) { newSrc.push( "#if __has_include()", "#import ", - "#endif", + "#endif" ); return mergeContents({ From 55fba4d766c83971877cc6334b08589406e86935 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Fri, 12 Jul 2024 16:09:22 +0100 Subject: [PATCH 2/9] Use ios prefix for ios properties --- packages/react-native-google-cast/src/withGoogleCast.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native-google-cast/src/withGoogleCast.ts b/packages/react-native-google-cast/src/withGoogleCast.ts index 37cae21b..122f2775 100644 --- a/packages/react-native-google-cast/src/withGoogleCast.ts +++ b/packages/react-native-google-cast/src/withGoogleCast.ts @@ -23,12 +23,12 @@ const withGoogleCast: ConfigPlugin< /** * @default true */ - startDiscoveryAfterFirstTapOnCastButton?: boolean; + iosStartDiscoveryAfterFirstTapOnCastButton?: boolean; /** * @default false */ - physicalVolumeButtonsWillControlDeviceVolume?: boolean; + iosPhysicalVolumeButtonsWillControlDeviceVolume?: boolean; } | void > = (config, _props) => { const props = _props || {}; @@ -37,9 +37,9 @@ const withGoogleCast: ConfigPlugin< receiverAppId: props.iosReceiverAppId, // disableDiscoveryAutostart?: boolean; startDiscoveryAfterFirstTapOnCastButton: - props.startDiscoveryAfterFirstTapOnCastButton, + props.iosStartDiscoveryAfterFirstTapOnCastButton, physicalVolumeButtonsWillControlDeviceVolume: - props.physicalVolumeButtonsWillControlDeviceVolume, + props.iosPhysicalVolumeButtonsWillControlDeviceVolume, }); config = withAndroidGoogleCast(config, { From e90a6aaeae952ffa7dbbc3bd9cde9abb1969f623 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Fri, 12 Jul 2024 16:09:31 +0100 Subject: [PATCH 3/9] Set repo name to @julianmx/react-native-google-cast-plugin-updates so we can publish to npm and clone from app --- packages/react-native-google-cast/package.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 90f47efd..660c91e8 100644 --- a/packages/react-native-google-cast/package.json +++ b/packages/react-native-google-cast/package.json @@ -1,6 +1,6 @@ { - "name": "@config-plugins/react-native-google-cast", - "version": "8.0.0", + "name": "@julianmx/react-native-google-cast-plugin-updates", + "version": "8.0.1", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/expo/config-plugins.git", + "url": "git+https://github.com/expo/config-plugins.git", "directory": "packages/react-native-google-cast" }, "files": [ @@ -34,5 +34,10 @@ "devDependencies": { "expo-module-scripts": "^3.5.1" }, - "upstreamPackage": "react-native-google-cast" + "upstreamPackage": "react-native-google-cast", + "bugs": { + "url": "https://github.com/expo/config-plugins/issues" + }, + "homepage": "https://github.com/expo/config-plugins#readme", + "author": "" } From 1ad4654cf75c53125db7b9e502b45b122a5af801 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Fri, 12 Jul 2024 16:11:36 +0100 Subject: [PATCH 4/9] update version to 8.0.2 --- packages/react-native-google-cast/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 660c91e8..190af807 100644 --- a/packages/react-native-google-cast/package.json +++ b/packages/react-native-google-cast/package.json @@ -1,6 +1,6 @@ { "name": "@julianmx/react-native-google-cast-plugin-updates", - "version": "8.0.1", + "version": "8.0.2", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", From c9518457c3ab966845d7a93f8ff70e2db8d1fc52 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Fri, 19 Jul 2024 11:35:39 +0100 Subject: [PATCH 5/9] Update readme --- packages/react-native-google-cast/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native-google-cast/README.md b/packages/react-native-google-cast/README.md index 90af6a2d..10f4f158 100644 --- a/packages/react-native-google-cast/README.md +++ b/packages/react-native-google-cast/README.md @@ -37,6 +37,8 @@ Next, rebuild your app as described in the ["Adding custom native code"](https:/ The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used. - `iosReceiverAppId` (_string_): unknown. Default `CC1AD845` +- `iosStartDiscoveryAfterFirstTapOnCastButton` (_boolean_) TODO +- `iosPhysicalVolumeButtonsWillControlDeviceVolume` (\_boolean) TODO - `androidReceiverAppId` (_string_): unknown. - `androidPlayServicesCastFrameworkVersion` (_string_): Version for the gradle package. Default `+` @@ -49,6 +51,8 @@ The plugin provides props for extra customization. Every time you change the pro "@config-plugins/react-native-google-cast", { "iosReceiverAppId": "...", + "iosStartDiscoveryAfterFirstTapOnCastButton": "...", + "iosPhysicalVolumeButtonsWillControlDeviceVolume": "...", "androidReceiverAppId": "...", "androidPlayServicesCastFrameworkVersion": "..." } From f37b238282d4e253431f996628e9600e57723b06 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Mon, 22 Jul 2024 13:37:21 +0100 Subject: [PATCH 6/9] Restore GuestMode and Bluetooth, microphone permissions since in release 4.8.2 of the iOS google-cast-sdk you no longer specify to use the no-bluetooth variant of the SDK so all permissions seem to be required Set version to 8.0.3 --- .../react-native-google-cast/package.json | 2 +- .../src/withIosGoogleCast.ts | 41 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 190af807..59107613 100644 --- a/packages/react-native-google-cast/package.json +++ b/packages/react-native-google-cast/package.json @@ -1,6 +1,6 @@ { "name": "@julianmx/react-native-google-cast-plugin-updates", - "version": "8.0.2", + "version": "8.0.3", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", diff --git a/packages/react-native-google-cast/src/withIosGoogleCast.ts b/packages/react-native-google-cast/src/withIosGoogleCast.ts index 32a71e5d..6e5677ea 100644 --- a/packages/react-native-google-cast/src/withIosGoogleCast.ts +++ b/packages/react-native-google-cast/src/withIosGoogleCast.ts @@ -22,12 +22,12 @@ const withIosWifiEntitlements: ConfigPlugin = (config) => { const LOCAL_NETWORK_USAGE = "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network"; -// const BLUETOOTH_ALWAYS_USAGE = -// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; -// const BLUETOOTH_PERIPHERAL_USAGE = -// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; -// const MICROPHONE_USAGE = -// "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices"; +const BLUETOOTH_ALWAYS_USAGE = + "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; +const BLUETOOTH_PERIPHERAL_USAGE = + "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; +const MICROPHONE_USAGE = + "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices"; /** * On iOS, a dialog asking the user for the local network permission will now be displayed immediately when the app is opened. @@ -62,19 +62,19 @@ const withIosLocalNetworkPermissions: ConfigPlugin<{ }); }; -// const withIosGuestMode: ConfigPlugin = (config) => { -// return withInfoPlist(config, (config) => { -// config.modResults.NSBluetoothAlwaysUsageDescription = -// config.modResults.NSBluetoothAlwaysUsageDescription || -// BLUETOOTH_ALWAYS_USAGE; -// config.modResults.NSBluetoothPeripheralUsageDescription = -// config.modResults.NSBluetoothPeripheralUsageDescription || -// BLUETOOTH_PERIPHERAL_USAGE; -// config.modResults.NSMicrophoneUsageDescription = -// config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; -// return config; -// }); -// }; +const withIosGuestMode: ConfigPlugin = (config) => { + return withInfoPlist(config, (config) => { + config.modResults.NSBluetoothAlwaysUsageDescription = + config.modResults.NSBluetoothAlwaysUsageDescription || + BLUETOOTH_ALWAYS_USAGE; + config.modResults.NSBluetoothPeripheralUsageDescription = + config.modResults.NSBluetoothPeripheralUsageDescription || + BLUETOOTH_PERIPHERAL_USAGE; + config.modResults.NSMicrophoneUsageDescription = + config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; + return config; + }); +}; // TODO: Use AppDelegate swizzling const withIosAppDelegateLoaded: ConfigPlugin = (config, props) => { @@ -126,8 +126,7 @@ export const withIosGoogleCast: ConfigPlugin<{ props.physicalVolumeButtonsWillControlDeviceVolume, }); - // TODO - // config = withIosGuestMode(config) + config = withIosGuestMode(config); return config; }; From bfc41afaf63c97592ab0c30c0be7ca5865a3861c Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Mon, 12 Aug 2024 11:19:25 +0100 Subject: [PATCH 7/9] Replace TODOs in readme --- packages/react-native-google-cast/README.md | 4 ++-- packages/react-native-google-cast/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-google-cast/README.md b/packages/react-native-google-cast/README.md index 10f4f158..ec487f4e 100644 --- a/packages/react-native-google-cast/README.md +++ b/packages/react-native-google-cast/README.md @@ -37,8 +37,8 @@ Next, rebuild your app as described in the ["Adding custom native code"](https:/ The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used. - `iosReceiverAppId` (_string_): unknown. Default `CC1AD845` -- `iosStartDiscoveryAfterFirstTapOnCastButton` (_boolean_) TODO -- `iosPhysicalVolumeButtonsWillControlDeviceVolume` (\_boolean) TODO +- `iosStartDiscoveryAfterFirstTapOnCastButton` (_boolean_) Default `true` +- `iosPhysicalVolumeButtonsWillControlDeviceVolume` (\_boolean) Default `false` - `androidReceiverAppId` (_string_): unknown. - `androidPlayServicesCastFrameworkVersion` (_string_): Version for the gradle package. Default `+` diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 59107613..0f6f60c5 100644 --- a/packages/react-native-google-cast/package.json +++ b/packages/react-native-google-cast/package.json @@ -1,6 +1,6 @@ { "name": "@julianmx/react-native-google-cast-plugin-updates", - "version": "8.0.3", + "version": "8.0.4", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", From d30e548095be029a8198e3149e7a90499aeaa703 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Tue, 13 Aug 2024 15:19:43 +0100 Subject: [PATCH 8/9] Revert changes add to mic/BT permissions to Info.plist since these are not required if we are correctly linking agains the latest iOS google-cast-sdk 4.8.1 --- .../src/withIosGoogleCast.ts | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/react-native-google-cast/src/withIosGoogleCast.ts b/packages/react-native-google-cast/src/withIosGoogleCast.ts index 6e5677ea..32a71e5d 100644 --- a/packages/react-native-google-cast/src/withIosGoogleCast.ts +++ b/packages/react-native-google-cast/src/withIosGoogleCast.ts @@ -22,12 +22,12 @@ const withIosWifiEntitlements: ConfigPlugin = (config) => { const LOCAL_NETWORK_USAGE = "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network"; -const BLUETOOTH_ALWAYS_USAGE = - "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; -const BLUETOOTH_PERIPHERAL_USAGE = - "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; -const MICROPHONE_USAGE = - "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices"; +// const BLUETOOTH_ALWAYS_USAGE = +// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; +// const BLUETOOTH_PERIPHERAL_USAGE = +// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices"; +// const MICROPHONE_USAGE = +// "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices"; /** * On iOS, a dialog asking the user for the local network permission will now be displayed immediately when the app is opened. @@ -62,19 +62,19 @@ const withIosLocalNetworkPermissions: ConfigPlugin<{ }); }; -const withIosGuestMode: ConfigPlugin = (config) => { - return withInfoPlist(config, (config) => { - config.modResults.NSBluetoothAlwaysUsageDescription = - config.modResults.NSBluetoothAlwaysUsageDescription || - BLUETOOTH_ALWAYS_USAGE; - config.modResults.NSBluetoothPeripheralUsageDescription = - config.modResults.NSBluetoothPeripheralUsageDescription || - BLUETOOTH_PERIPHERAL_USAGE; - config.modResults.NSMicrophoneUsageDescription = - config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; - return config; - }); -}; +// const withIosGuestMode: ConfigPlugin = (config) => { +// return withInfoPlist(config, (config) => { +// config.modResults.NSBluetoothAlwaysUsageDescription = +// config.modResults.NSBluetoothAlwaysUsageDescription || +// BLUETOOTH_ALWAYS_USAGE; +// config.modResults.NSBluetoothPeripheralUsageDescription = +// config.modResults.NSBluetoothPeripheralUsageDescription || +// BLUETOOTH_PERIPHERAL_USAGE; +// config.modResults.NSMicrophoneUsageDescription = +// config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE; +// return config; +// }); +// }; // TODO: Use AppDelegate swizzling const withIosAppDelegateLoaded: ConfigPlugin = (config, props) => { @@ -126,7 +126,8 @@ export const withIosGoogleCast: ConfigPlugin<{ props.physicalVolumeButtonsWillControlDeviceVolume, }); - config = withIosGuestMode(config); + // TODO + // config = withIosGuestMode(config) return config; }; From 78f4fbb7642d0afe5cb4096a0f04dc5f4c36bde2 Mon Sep 17 00:00:00 2001 From: Julian Diggle Date: Tue, 13 Aug 2024 15:20:06 +0100 Subject: [PATCH 9/9] Revert changes to cast package.json --- packages/react-native-google-cast/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 0f6f60c5..034959ce 100644 --- a/packages/react-native-google-cast/package.json +++ b/packages/react-native-google-cast/package.json @@ -1,6 +1,6 @@ { - "name": "@julianmx/react-native-google-cast-plugin-updates", - "version": "8.0.4", + "name": "@config-plugins/react-native-google-cast", + "version": "8.0.1", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/expo/config-plugins.git", + "url": "https://github.com/expo/config-plugins.git", "directory": "packages/react-native-google-cast" }, "files": [