# GCKCastContext Class

[Instance Methods](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#pub-methods) \| [Class Methods](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#pub-static-methods) \| [Public Attributes](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#pub-attribs) \| [Properties](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#properties) GCKCastContext Class Reference

## Overview

A class containing global objects and state for the framework.

The context must be initialized early in the application's lifecycle via a call to [setSharedInstanceWithOptions: (GCKCastContext)](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6a4f21559bb295c93e76b6707aed5da2).

Since
:   3.0

Inherits NSObject.

|---|---|
| ## Instance Method Summary ||
| (void) | - [registerDeviceProvider:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a09f0c6e0aa504e2339684e422eac5b11) |
|   | Registers a device provider, which adds support for a new type of (non-Cast) device. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a09f0c6e0aa504e2339684e422eac5b11) |
|   ||
| (void) | - [unregisterDeviceProviderForCategory:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#afded8d8fc4d00b1bb67fa0abc34d0027) |
|   | Unregisters the device provider for a given device category. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#afded8d8fc4d00b1bb67fa0abc34d0027) |
|   ||
| (void) | - [presentCastDialog](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a587f4a06112eb77ada412dddf27c3b9c) |
|   | Displays the Cast dialog. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a587f4a06112eb77ada412dddf27c3b9c) |
|   ||
| ([GCKUICastContainerViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_cast_container_view_controller) \*) | - [createCastContainerControllerForViewController:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6c9707e89dce9c0b0a87e90f04fbe132) |
|   | Constructs a [GCKUICastContainerViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_cast_container_view_controller "A view controller which wraps another View Controller and adds a media playback notification area bel...") that embeds the given view controller. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6c9707e89dce9c0b0a87e90f04fbe132) |
|   ||
| ([GCKUIMiniMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_mini_media_controls_view_controller) \*) | - [createMiniMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ab26e1d13aa2a56f2fc158be68982c37e) |
|   | Constructs a [GCKUIMiniMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_mini_media_controls_view_controller "A view controller which implements the \"now playing\" control bar. "). [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ab26e1d13aa2a56f2fc158be68982c37e) |
|   ||
| (BOOL) | - [presentCastInstructionsViewControllerOnce](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ab714866063a7d91b9e74b534e1b55b8f) |
|   | If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button and displays some brief instructional text about its use. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ab714866063a7d91b9e74b534e1b55b8f) |
|   ||
| (void) | - [clearCastInstructionsShownFlag](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a193a998852da3c693bf418e0ac097aa3) |
|   | Clears the persistent flag that tracks whether the Cast instructions modal view controller has been shown. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a193a998852da3c693bf418e0ac097aa3) |
|   ||
| (void) | - [presentDefaultExpandedMediaControls](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aa40df0cf4812368e508730e30859b1cd) |
|   | Displays the default Cast expanded media controls. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aa40df0cf4812368e508730e30859b1cd) |
|   ||

|---|---|
| ## Class Method Summary ||
| (void) | + [setSharedInstanceWithOptions:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6a4f21559bb295c93e76b6707aed5da2) |
|   | Sets the shared instance, supplying a Cast options object. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6a4f21559bb295c93e76b6707aed5da2) |
|   ||
| (instancetype) | + [sharedInstance](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ad04945f49edf25d89a7b6c46662de632) |
|   | Returns the singleton instance. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ad04945f49edf25d89a7b6c46662de632) |
|   ||
| (BOOL) | + [isSharedInstanceInitialized](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a5b2e6fb29aa6955bee1a12ebbd118e3f) |
|   | Tests if the singleton instance has been initialized yet. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a5b2e6fb29aa6955bee1a12ebbd118e3f) |
|   ||

|---|---|
| ## Public Attributes ||
| NSString \*const | [kGCKNotificationKeyCastState](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a130bd9bf1901d46ffb3a7e0e73af4c3a) |
|   | The `userInfo` key for the new Cast state in a Cast state change notification. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a130bd9bf1901d46ffb3a7e0e73af4c3a) |
|   ||
| NSString \*const | [kGCKCastStateDidChangeNotification](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#af098de1cd38576e7bc786fe2d4bf88eb) |
|   | The name of the notification that will be published when the Cast state changes. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#af098de1cd38576e7bc786fe2d4bf88eb) |
|   ||
| NSString \*const | [kGCKUICastDialogWillShowNotification](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aae937e27d5f0c1f47171b41efb5676fc) |
|   | The name of the notification that will be published when the Cast dialog is about to be shown. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aae937e27d5f0c1f47171b41efb5676fc) |
|   ||
| NSString \*const | [kGCKUICastDialogDidHideNotification](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a65597ef92c25c514e3b807898d0481d3) |
|   | The name of the notification that will be published when the Cast dialog has been dismissed. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a65597ef92c25c514e3b807898d0481d3) |
|   ||

|---|---|
| ## Property Summary ||
| [GCKCastState](https://developers.google.com/cast/v3/reference/ios/g_c_k_common_8h#af0c098ac6b7bff89f13f0bad7b88a5b5) | [castState](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a41a8b6a12d778a4ea763b0b7d1141c54) |
|   | The current casting state for the application. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a41a8b6a12d778a4ea763b0b7d1141c54) |
|   ||
| [GCKDiscoveryManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_discovery_manager) \* | [discoveryManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aa99aebcd1cb1b0612d3a25e18499a0a2) |
|   | The discovery manager. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#aa99aebcd1cb1b0612d3a25e18499a0a2) |
|   ||
| [GCKSessionManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_session_manager) \* | [sessionManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6c80ecf1ab4b47632c0c90cf19c207c7) |
|   | The session manager. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a6c80ecf1ab4b47632c0c90cf19c207c7) |
|   ||
| id\< [GCKUIImageCache](https://developers.google.com/cast/v3/reference/ios/protocol_g_c_k_u_i_image_cache-p) \> | [imageCache](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a9b83c154f8700cb322f9cf42738bd98a) |
|   | The image cache implementation that will be used by the framework to fetch images that are referenced in media metadata. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a9b83c154f8700cb322f9cf42738bd98a) |
|   ||
| id\< [GCKUIImagePicker](https://developers.google.com/cast/v3/reference/ios/protocol_g_c_k_u_i_image_picker-p) \> | [imagePicker](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ada8e8d94275d23c230956e5146d19633) |
|   | The image picker implementation that will be used to select an image for a specific purpose. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#ada8e8d94275d23c230956e5146d19633) |
|   ||
| BOOL | [useDefaultExpandedMediaControls](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a678506847c6b5769ebbe54f7a4ae1471) |
|   | Configures the behavior of the Framework when there's a user action that should result in the presentation of the expanded controls. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a678506847c6b5769ebbe54f7a4ae1471) |
|   ||
| [GCKUIExpandedMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_expanded_media_controls_view_controller) \* | [defaultExpandedMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a23608ffbd072151644384d044988e184) |
|   | The instance of the default Cast expanded media controls view controller. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#a23608ffbd072151644384d044988e184) |
|   ||

## Method Detail

|---|---|---|---|---|
| + (void) setSharedInstanceWithOptions: |   | ([GCKCastOptions](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_options) \*) | *options* |   |

Sets the shared instance, supplying a Cast options object.

If the shared instance is already initialized, an exception will be thrown. This method must be called on the main thread.

|---|---|---|---|
| + (instancetype) sharedInstance |   |   |   |

Returns the singleton instance.

If a shared instance has not yet been initialized, an exception will be thrown.

|---|---|---|---|
| + (BOOL) isSharedInstanceInitialized |   |   |   |

Tests if the singleton instance has been initialized yet.

Since
:   3.5.4

|---|---|---|---|---|
| - (void) registerDeviceProvider: |   | ([GCKDeviceProvider](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_device_provider) \*) | *deviceProvider* |   |

Registers a device provider, which adds support for a new type of (non-Cast) device.

Parameters
:

    |---|---|
    | deviceProvider | An instance of a [GCKDeviceProvider](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_device_provider "An abstract base class for performing device discovery and session construction. ") subclass for managing the devices. |


|---|---|---|---|---|
| - (void) unregisterDeviceProviderForCategory: |   | (NSString \*) | *category* |   |

Unregisters the device provider for a given device category.

Parameters
:

    |---|---|
    | category | A string that uniquely identifies the type of device. |


|---|---|---|---|
| - (void) presentCastDialog |   |   |   |

Displays the Cast dialog.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a587f4a06112eb77ada412dddf27c3b9c).

|---|---|---|---|---|
| - ([GCKUICastContainerViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_cast_container_view_controller) \*) createCastContainerControllerForViewController: |   | (UIViewController \*) | *viewController* |   |

Constructs a [GCKUICastContainerViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_cast_container_view_controller "A view controller which wraps another View Controller and adds a media playback notification area bel...") that embeds the given view controller.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a6c9707e89dce9c0b0a87e90f04fbe132).

|---|---|---|---|
| - ([GCKUIMiniMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_mini_media_controls_view_controller) \*) createMiniMediaControlsViewController |   |   |   |

Constructs a [GCKUIMiniMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_mini_media_controls_view_controller "A view controller which implements the \"now playing\" control bar. ").

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#ab26e1d13aa2a56f2fc158be68982c37e).

|---|---|---|---|
| - (BOOL) presentCastInstructionsViewControllerOnce |   |   |   |

If it has not been shown before, presents a fullscreen modal view controller that calls attention to the Cast button and displays some brief instructional text about its use.

Returns
:   `YES` if the view controller was shown, `NO` if it was not shown because it had already been shown before.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#ab714866063a7d91b9e74b534e1b55b8f).

|---|---|---|---|
| - (void) clearCastInstructionsShownFlag |   |   |   |

Clears the persistent flag that tracks whether the Cast instructions modal view controller has been shown.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a193a998852da3c693bf418e0ac097aa3).

|---|---|---|---|
| - (void) presentDefaultExpandedMediaControls |   |   |   |

Displays the default Cast expanded media controls.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#aa40df0cf4812368e508730e30859b1cd).

## Member Data Documentation

|---|
| - (NSString\* const) kGCKNotificationKeyCastState |

The `userInfo` key for the new Cast state in a Cast state change notification.

|---|
| - (NSString\* const) kGCKCastStateDidChangeNotification |

The name of the notification that will be published when the Cast state changes.

|---|
| - (NSString\* const) kGCKUICastDialogWillShowNotification |

The name of the notification that will be published when the Cast dialog is about to be shown.

Since
:   3.4

|---|
| - (NSString\* const) kGCKUICastDialogDidHideNotification |

The name of the notification that will be published when the Cast dialog has been dismissed.

Since
:   3.4

## Property Detail

|---|---|
| |---| | - ([GCKCastState](https://developers.google.com/cast/v3/reference/ios/g_c_k_common_8h#af0c098ac6b7bff89f13f0bad7b88a5b5)) castState | | readnonatomicassign |

The current casting state for the application.

Changes to this property can be monitored with KVO or by listening for [kGCKCastStateDidChangeNotification](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_cast_context#af098de1cd38576e7bc786fe2d4bf88eb) notifications.

|---|---|
| |---| | - ([GCKDiscoveryManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_discovery_manager)\*) discoveryManager | | readnonatomicstrong |

The discovery manager.

This object handles the discovery of receiver devices.

|---|---|
| |---| | - ([GCKSessionManager](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_session_manager)\*) sessionManager | | readnonatomicstrong |

The session manager.

This object manages the interaction with receiver devices.

|---|---|
| |---| | - (id\<[GCKUIImageCache](https://developers.google.com/cast/v3/reference/ios/protocol_g_c_k_u_i_image_cache-p)\>) imageCache | | readwritenonatomicstrong |

The image cache implementation that will be used by the framework to fetch images that are referenced in media metadata.

A default implementation will be used if one is not provided by the application. May be set to `nil` to reinstate the default image cache.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a9b83c154f8700cb322f9cf42738bd98a).

|---|---|
| |---| | - (id\<[GCKUIImagePicker](https://developers.google.com/cast/v3/reference/ios/protocol_g_c_k_u_i_image_picker-p)\>) imagePicker | | readwritenonatomicstrong |

The image picker implementation that will be used to select an image for a specific purpose.

A default implementation will be used if one is not provided by the application. May be set to `nil` to reinstate the default image picker.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#ada8e8d94275d23c230956e5146d19633).

|---|---|
| |---| | - (BOOL) useDefaultExpandedMediaControls | | readwritenonatomicassign |

Configures the behavior of the Framework when there's a user action that should result in the presentation of the expanded controls.

If `YES`, the Framework will present the default expaned controls view. If `NO`, the Framework will just trigger a [GCKUICastContainerViewController::kGCKExpandedMediaControlsTriggeredNotification](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_cast_container_view_controller#a8656b0b33d63678b90d5d94608f43127).

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a678506847c6b5769ebbe54f7a4ae1471).

|---|---|
| |---| | - ([GCKUIExpandedMediaControlsViewController](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_u_i_expanded_media_controls_view_controller)\*) defaultExpandedMediaControlsViewController | | readnonatomicstrong |

The instance of the default Cast expanded media controls view controller.

Provided by category [GCKCastContext(UI)](https://developers.google.com/cast/v3/reference/ios/category_g_c_k_cast_context_07_u_i_08#a23608ffbd072151644384d044988e184).