diff --git a/packages/react-native-google-cast/README.md b/packages/react-native-google-cast/README.md index 90af6a2d..ec487f4e 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_) Default `true` +- `iosPhysicalVolumeButtonsWillControlDeviceVolume` (\_boolean) Default `false` - `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": "..." } diff --git a/packages/react-native-google-cast/package.json b/packages/react-native-google-cast/package.json index 90f47efd..034959ce 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", + "version": "8.0.1", "description": "Config plugin to auto configure Google Cast on prebuild", "main": "build/withGoogleCast.js", "types": "build/withGoogleCast.d.ts", @@ -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": "" } diff --git a/packages/react-native-google-cast/src/withGoogleCast.ts b/packages/react-native-google-cast/src/withGoogleCast.ts index ce2ba06d..122f2775 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 + */ + iosStartDiscoveryAfterFirstTapOnCastButton?: boolean; + + /** + * @default false + */ + iosPhysicalVolumeButtonsWillControlDeviceVolume?: 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.iosStartDiscoveryAfterFirstTapOnCastButton, + physicalVolumeButtonsWillControlDeviceVolume: + props.iosPhysicalVolumeButtonsWillControlDeviceVolume, }); 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({