Skip to content

Commit

Permalink
Merge pull request #1738 from flexn-io/fix/google-cast
Browse files Browse the repository at this point in the history
fix google cast not working
  • Loading branch information
pauliusguzas authored Oct 7, 2024
2 parents 1be5fa3 + 858c55d commit ec76442
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 53 deletions.
3 changes: 0 additions & 3 deletions packages/app-harness/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@
}
},
"react-native-google-cast": {
"ios": {
"disabled": true
},
"androidwear": {
"disabled": true
},
Expand Down

This file was deleted.

36 changes: 36 additions & 0 deletions packages/app-harness/src/components/CastButton/index.mobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Button, View } from 'react-native';
import { CastButton, CastContext } from 'react-native-google-cast';
import { testProps } from '../../config';
import { useLoggerContext } from '../../context';

export function CastComponent() {
const { logDebug } = useLoggerContext();
return (
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around' }}>
<CastButton
{...testProps('app-harness-home-cast-support-button')}
style={{ width: 24, height: 24, tintColor: 'black' }}
/>
<Button
title="Load Media"
onPress={async () => {
try {
const client = (await CastContext.getSessionManager().getCurrentCastSession())?.client;
if (!client) {
logDebug(`Cast: client is "${client}"`);
return;
}
await client.loadMedia({
mediaInfo: {
contentUrl:
'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4',
},
});
} catch (e) {
logDebug(`Cast: ${e}`);
}
}}
/>
</View>
);
}
5 changes: 4 additions & 1 deletion packages/app-harness/test/specs/e2e.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ describe('Test App Harness', () => {
await FlexnRunner.expectToBeDisplayedByText('Cast to');
await FlexnRunner.waitForDisplayedByText('OK');
await FlexnRunner.expectToBeDisplayedByText('OK');
} else if (process.env.PLATFORM === 'ios') {
await FlexnRunner.clickById('app-harness-home-cast-support-button');
await FlexnRunner.expectToBeDisplayedByText('Cast to');
} else {
await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported');
}
}
});
});
34 changes: 10 additions & 24 deletions packages/config-templates/renative.templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -2599,39 +2599,23 @@
},
"ios": {
"templateXcode": {
"appDelegateImports": [
"GoogleCast"
],
"AppDelegate_mm": {
"appDelegateImports": [
"GoogleCast/GoogleCast.h"
],
"appDelegateImports": ["GoogleCast/GoogleCast.h"],
"appDelegateMethods": {
"application": {
"didFinishLaunchingWithOptions": [
"NSString *receiverAppID = kGCKDefaultMediaReceiverApplicationID; // or @\"ABCD1234\"",
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID];",
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria];",
"[GCKCastContext setSharedInstanceWithOptions:options];"
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID]",
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria]",
"options.disableDiscoveryAutostart = {{props.DISABLE_DISCOVERY_AUTOSTART}}",
"options.startDiscoveryAfterFirstTapOnCastButton = {{props.START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON}}",
"[GCKCastContext setSharedInstanceWithOptions:options]"
]
}
}
},
"appDelegateMethods": {
"application": {
"didFinishLaunchingWithOptions": [
"let receiverAppID = \"{{props.APPLICATION_ID}}\" // or \"ABCD1234\"",
"let criteria = GCKDiscoveryCriteria(applicationID: receiverAppID)",
"let options = GCKCastOptions(discoveryCriteria: criteria)",
"GCKCastContext.setSharedInstanceWith(options)"
]
}
},
"Info_plist": {
"NSBonjourServices": [
"_googlecast._tcp",
"_CC1AD845._googlecast._tcp"
],
"NSBonjourServices": ["_googlecast._tcp", "_CC1AD845._googlecast._tcp"],
"NSLocalNetworkUsageDescription": "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network."
}
},
Expand All @@ -2640,7 +2624,9 @@
"podName": "react-native-google-cast/NoBluetoothArm"
},
"props": {
"APPLICATION_ID": "01234"
"APPLICATION_ID": "01234",
"DISABLE_DISCOVERY_AUTOSTART": "false",
"START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON": "false"
},
"version": "4.8.0"
},
Expand Down

0 comments on commit ec76442

Please sign in to comment.