From 688c343a352b7a267dbbafc8802907f0d25a6c24 Mon Sep 17 00:00:00 2001 From: jakequade Date: Sun, 25 Aug 2024 00:03:34 +1000 Subject: [PATCH] iOS support --- app.json | 1 + plugins/withExpandedController.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/withExpandedController.js diff --git a/app.json b/app.json index ad62a054..18082398 100644 --- a/app.json +++ b/app.json @@ -74,6 +74,7 @@ "com.reactnative.googlecast.RNGCExpandedControllerActivity": true } ], + ["./plugins/withExpandedController.js"], [ "expo-build-properties", { diff --git a/plugins/withExpandedController.js b/plugins/withExpandedController.js new file mode 100644 index 00000000..9ea30dcd --- /dev/null +++ b/plugins/withExpandedController.js @@ -0,0 +1,20 @@ +const { withAppDelegate } = require("@expo/config-plugins"); + +const withExpandedController = (config) => { + return withAppDelegate(config, async (config) => { + const contents = config.modResults.contents; + + // Looking for the initialProps string inside didFinishLaunchingWithOptions, + // and injecting expanded controller config. + // Should be updated once there is an expo config option - see https://github.com/react-native-google-cast/react-native-google-cast/discussions/537 + const injectionIndex = contents.indexOf("self.initialProps = @{};"); + config.modResults.contents = + contents.substring(0, injectionIndex) + + `\n [GCKCastContext sharedInstance].useDefaultExpandedMediaControls = true; \n` + + contents.substring(injectionIndex); + + return config; + }); +}; + +module.exports = withExpandedController;