I'm trying to build a sample app using the GoogleCast sdk. I'm stuck at the first step.
For some weird reason, I'm unable to create the cast container in Obj-c.
I'm not using the pods. I downloaded the frameworks and added them to the project.
Here is the method I call in AppDelegate didFinishLaunching method:
-(void)setupChromeCastContainer {
GCKDiscoveryCriteria *discoveryCriteria = [[GCKDiscoveryCriteria alloc]initWithApplicationID:kGCKDefaultMediaReceiverApplicationID];
GCKCastOptions *options = [[GCKCastOptions alloc]initWithDiscoveryCriteria:discoveryCriteria];
[GCKCastContext setSharedInstanceWithOptions:options];
[GCKCastContext sharedInstance].useDefaultExpandedMediaControls = YES;
UIStoryboard *st = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *nav = [st instantiateViewControllerWithIdentifier:@"navVc"];
GCKUICastContainerViewController * containerVc = [[GCKCastContext sharedInstance]createCastContainerControllerForViewController:nav];
containerVc.miniMediaControlsItemEnabled = YES;
self.window.rootViewController = containerVc;
[self.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self setupChromeCastContainer];
return YES;
}
In the above method, GCKUICastContainerViewController * containerVc
is returning nil. And also the nav is NOT nil, so I'm passing the valid object.
I'm unable to find why createCastContainerControllerForViewController
returns nil or in which case it returns nil.
My environment is Xcode 11.3.1.
I even tried to add the cast button to the nav bar, and cast button code returns nil too.
GCKUICastButton *castButton = [[GCKUICastButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)]; //castButton returns nill