Skip to content

Commit ec76442

Browse files
authored
Merge pull request #1738 from flexn-io/fix/google-cast
fix google cast not working
2 parents 1be5fa3 + 858c55d commit ec76442

File tree

5 files changed

+50
-53
lines changed

5 files changed

+50
-53
lines changed

packages/app-harness/renative.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@
259259
}
260260
},
261261
"react-native-google-cast": {
262-
"ios": {
263-
"disabled": true
264-
},
265262
"androidwear": {
266263
"disabled": true
267264
},

packages/app-harness/src/components/CastButton/index.android.mobile.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Button, View } from 'react-native';
2+
import { CastButton, CastContext } from 'react-native-google-cast';
3+
import { testProps } from '../../config';
4+
import { useLoggerContext } from '../../context';
5+
6+
export function CastComponent() {
7+
const { logDebug } = useLoggerContext();
8+
return (
9+
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around' }}>
10+
<CastButton
11+
{...testProps('app-harness-home-cast-support-button')}
12+
style={{ width: 24, height: 24, tintColor: 'black' }}
13+
/>
14+
<Button
15+
title="Load Media"
16+
onPress={async () => {
17+
try {
18+
const client = (await CastContext.getSessionManager().getCurrentCastSession())?.client;
19+
if (!client) {
20+
logDebug(`Cast: client is "${client}"`);
21+
return;
22+
}
23+
await client.loadMedia({
24+
mediaInfo: {
25+
contentUrl:
26+
'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4',
27+
},
28+
});
29+
} catch (e) {
30+
logDebug(`Cast: ${e}`);
31+
}
32+
}}
33+
/>
34+
</View>
35+
);
36+
}

packages/app-harness/test/specs/e2e.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ describe('Test App Harness', () => {
7272
await FlexnRunner.expectToBeDisplayedByText('Cast to');
7373
await FlexnRunner.waitForDisplayedByText('OK');
7474
await FlexnRunner.expectToBeDisplayedByText('OK');
75+
} else if (process.env.PLATFORM === 'ios') {
76+
await FlexnRunner.clickById('app-harness-home-cast-support-button');
77+
await FlexnRunner.expectToBeDisplayedByText('Cast to');
7578
} else {
7679
await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported');
77-
}
80+
}
7881
});
7982
});

packages/config-templates/renative.templates.json

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,39 +2599,23 @@
25992599
},
26002600
"ios": {
26012601
"templateXcode": {
2602-
"appDelegateImports": [
2603-
"GoogleCast"
2604-
],
26052602
"AppDelegate_mm": {
2606-
"appDelegateImports": [
2607-
"GoogleCast/GoogleCast.h"
2608-
],
2603+
"appDelegateImports": ["GoogleCast/GoogleCast.h"],
26092604
"appDelegateMethods": {
26102605
"application": {
26112606
"didFinishLaunchingWithOptions": [
26122607
"NSString *receiverAppID = kGCKDefaultMediaReceiverApplicationID; // or @\"ABCD1234\"",
2613-
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID];",
2614-
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria];",
2615-
"[GCKCastContext setSharedInstanceWithOptions:options];"
2608+
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID]",
2609+
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria]",
2610+
"options.disableDiscoveryAutostart = {{props.DISABLE_DISCOVERY_AUTOSTART}}",
2611+
"options.startDiscoveryAfterFirstTapOnCastButton = {{props.START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON}}",
2612+
"[GCKCastContext setSharedInstanceWithOptions:options]"
26162613
]
26172614
}
26182615
}
26192616
},
2620-
"appDelegateMethods": {
2621-
"application": {
2622-
"didFinishLaunchingWithOptions": [
2623-
"let receiverAppID = \"{{props.APPLICATION_ID}}\" // or \"ABCD1234\"",
2624-
"let criteria = GCKDiscoveryCriteria(applicationID: receiverAppID)",
2625-
"let options = GCKCastOptions(discoveryCriteria: criteria)",
2626-
"GCKCastContext.setSharedInstanceWith(options)"
2627-
]
2628-
}
2629-
},
26302617
"Info_plist": {
2631-
"NSBonjourServices": [
2632-
"_googlecast._tcp",
2633-
"_CC1AD845._googlecast._tcp"
2634-
],
2618+
"NSBonjourServices": ["_googlecast._tcp", "_CC1AD845._googlecast._tcp"],
26352619
"NSLocalNetworkUsageDescription": "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network."
26362620
}
26372621
},
@@ -2640,7 +2624,9 @@
26402624
"podName": "react-native-google-cast/NoBluetoothArm"
26412625
},
26422626
"props": {
2643-
"APPLICATION_ID": "01234"
2627+
"APPLICATION_ID": "01234",
2628+
"DISABLE_DISCOVERY_AUTOSTART": "false",
2629+
"START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON": "false"
26442630
},
26452631
"version": "4.8.0"
26462632
},

0 commit comments

Comments
 (0)