Skip to content

Commit

Permalink
iOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
jakequade committed Aug 24, 2024
1 parent fb6e3dc commit 688c343
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"com.reactnative.googlecast.RNGCExpandedControllerActivity": true
}
],
["./plugins/withExpandedController.js"],
[
"expo-build-properties",
{
Expand Down
20 changes: 20 additions & 0 deletions plugins/withExpandedController.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 688c343

Please sign in to comment.