Migrate iOS Sender App from Cast SDK v2 to v3

The following procedure enables you to convert your iOS sender app from Cast SDK v2 to v3, which is based on the GCKCastContext singleton.


  • The iOS Cast SDK v3 is still distributed on the Google Cast developer website and CocoaPods, like v2.
  • New classes have been added that take on responsibility for complying with the Google Cast design checklist.
  • iOS SDK v3 provides widgets that comply with the Cast UX requirements; v2 did not provide any UI components and required you to implement these widgets.
  • iOS SDK v3 design is consistent with the Cast Android SDK design.
  • iOS SDK v3 supports Bitcode, like v2.
  • Closed captioning in v3 is similar to v2.


V3 supports iOS version 8 and later.


In v3, an explicit initialization step is required for the Cast framework. This involves initializing the GCKCastContext singleton, using an appropriate GCKCastOptions to specify the receiver application ID and any other global options. This is typically done in the AppDelegate -[application:didFinishLaunchingWithOptions:] method:

GCKCastOptions *options = [[GCKCastOptions alloc]
[GCKCastContext setSharedInstanceWithOptions:options];

This step was not necessary in v2.

Device Discovery

In v3, the discovery process is started and stopped automatically by the framework when the app comes to the foreground and goes to the background, respectively. The GCKDeviceScanner and GCKFilterCriteria classes from v2 are deprecated and should not be used.

Cast Button and Cast Dialog

In v3, the Cast button and dialog are provided by the framework. The Cast button can be instantiated and added to the navigation bar as follows:

GCKUICastButton *castButton =
    [[GCKUICastButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
castButton.tintColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem =
    [[UIBarButtonItem alloc] initWithCustomView:castButton];

The Cast button can also be added to the storyboard.

When someone taps the button, the Cast dialog is presented automatically.

Device Control

In v3, device control is largely handled by the framework. The sender application does not need to handle connecting to the device and launching the receiver application. The v2 class GCKDeviceManager is deprecated and should not be used. Interaction between sender and receiver is now represented as a "session". The v3 GCKSessionManager class handles session lifecycle and automatically starts and stops sessions in response to user gestures: a session is started when the user selects a Cast device in the Cast dialog and is ended when the user taps the "Stop Casting" button in the Cast dialog or when the sender app itself terminates. The sender application can be notified of session lifecycle events by registering a GCKSessionManagerListener with the GCKSessionManager. The GCKSessionManagerListener protocol defines callback methods for all session lifecycle events.

The GCKCastSession class represents a session with a Cast device. The class has methods for controlling the device volume and mute states, which was previously done in v2 using methods on GCKDeviceManager.

In v2, the GCKDeviceManagerDelegate protocol provided notifications of changes to the device state, including volume, mute state, standby status, and so on. In v3, volume/mute state change notifications are delivered via callback methods in the GCKSessionManagerListener protocol; these listeners are registered with the GCKSessionManager. All of the remaining device state notifications are delivered via a GCKCastDeviceStatusListener protocol; these listeners are registered with the GCKCastSession.

Reconnection Logic

As with v2, the v3 framework attempts to re-establish network connections that are lost due to temporary WiFi signal loss or other network errors. This is now done at the session level; a session can enter a "suspended" state when the connection is lost, and will transition back to a "connected" state when connectivity is restored. The framework takes care of reconnecting to the receiver application and reconnecting any Cast channels as part of this process.

In addition, v3 also adds automatic session resumption. If the sender application is sent to the background or is terminated (by swiping-away or because of a crash) while a Cast session is in progress, the framework will attempt to resume that session when the sender application returns to the foreground or is relaunched; this is handled automatically by the GCKSessionManager, which will issue the appropriate callbacks on any registered GCKSessionManagerListener instances.

Custom Channel Registration

In v2, custom channels (implemented using either a GCKCastChannel subclass or a GCKGenericChannel and delegate) were registered with the GCKDeviceManager. In v3, custom channels are instead registered with the GCKCastSession instance. The registration can be done in the GCKSessionManagerListener -[sessionManager:didStartCastSession:] callback method. For media applications, it is no longer necessary to explicitly register the GCKMediaControlChannel; see the following section for more details.

Media Control

The v2 class GCKMediaControlChannel is deprecated and should not be used. In v3, it is superseded by the new GCKRemoteMediaClient class, which provides equivalent functionality in a more convenient API. It is not necessary to explicitly initialize or register this object; the framework will automatically instantiate the object and register the underlying media channel at session start time if the receiver application being connected to supports the media namespace.

The GCKRemoteMediaClient can be accessed with the -[remoteMediaClient] property of the GCKCastSession object.

In v2, all media requests issued on the GCKMediaControlChannel would return a numeric request ID, and methods on GCKMediaControlChannelDelegate would provide this ID when sending notifications about request completion or failure.

In v3, all media requests issued on the GCKRemoteMediaClient will return a GCKRequest object; this object has an associated GCKRequestDelegate protocol which can be used to track the progress and eventual outcome of the request.

The v2 GCKMediaControlChannel; would send notifications about changes in the media player state on the receiver via the GCKMediaControlChannelDelegate. In v3, the GCKRemoteMediaClient provides equivalent callbacks via its GCKRemoteMediaClientListener protocol. Any number of listeners can be registered with the GCKRemoteMediaClient, which allows multiple sender components to share the single instance of GCKRemoteMediaClient that is associated with the session.

In v2, the sender application had to take on the burden of keeping the user interface in sync with the media player state on the receiver. In v3, the class GCKUIMediaController takes on most of this responsibility; see the codelab tutorial documentation for examples on how to use this component.

Introductory Overlay

V2 does not provide an introductory overlay UI.

V3 adds class GCKCastContext with a method -[presentCastInstructionsViewControllerOnce] that a sender app can use to highlight the Cast button when it is first shown to users.

Mini Controller

In v2, you need to implement a mini controller from scratch in the sender app.

In v3, the framework provides a control bar, GCKUIMiniMediaControlsViewController, which you can add to the scenes where you want to show the persistent controls. There are two ways to add the mini controller to a sender app:

Expanded Controller

In v2, you need to implement an expanded controller from scratch in the sender app.

V3.0 adds GCKUIMediaController, which you could use to more easily implement an expanded controller.

V3.1 adds a pre-built expanded controller widget GCKUIExpandedMediaControlsViewController which you can simply add to your app. You no longer need to implement a custom expanded controller using GCKUIMediaController.

Debug Logging

The GCKLogger and GCKLoggerDelegate classes from v2 are carried over into v3, with some changes and enhancements.

The GCKLoggerDelegate -[logFromFunction:message:] method has been deprecated in favor of -[logMessage:fromFunction:].

Framework log messages can now be filtered by constructing an appropriate GCKLoggerFilter instance and assigning it by setting the -[filter] property of the GCKLogger singleton.

Sample Apps

We recommend looking at the codelabs and sample apps written for the Cast SDK v3.