GCKOpen网址Options 类
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
一个对象,表示可通过深层链接网址传递给支持 Cast 的应用的选项。
源应用使用 asURLQueryItem (GCKOpenURLOptions) 在应用网址的查询参数中编码 Cast 专用选项(包括要投射到的设备的唯一 ID,以及要加入的特定 Cast 会话的会话 ID),然后使用 UIApplication 的 -[openURL:options:completionHandler:]
方法打开该网址。目标应用通过调用 openURLOptionsFromURL: (GCKOpenURLOptions) 从其 UIApplicationDelegate 的 -[application:openURL:options:]
方法中收到的网址中提取 Cast 专用选项。然后,通过将这些选项传递给 startSessionWithOpenURLOptions:sessionOptions: (GCKSessionManager),它启动或加入 Cast 会话。
- 开始时间
- 4.0
继承 NSObject、<NSCopy> 和 <NSSecureCoding>。
从指定网址中提取 Cast 专用选项。
- 返回
- 提取的选项,或者如果网址不包含任何 Cast 专用选项,则为
nil
。
- (NSURLQueryItem *) asURLQueryItem |
|
|
|
将选项转换为网址查询项。
- 返回
- 作为 NS网址QueryItem 的选项。
- (NSString*) deviceUniqueID |
|
readwritenonatomiccopy |
- (NSString*) deviceFriendlyName |
|
readwritenonatomiccopy |
要连接到的设备的易记名称。
可选。GoogleCast 框架不会使用此值,但接收应用可能会关注该值。
要加入的 Cast 会话的会话 ID。
可选。值 nil
表示应加入任何当前处于活动状态的会话;如果还没有,应创建新的会话。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003ccode\u003eGCKOpenURLOptions\u003c/code\u003e enables deep-linking to Cast-enabled applications by encoding Cast-specific options within a URL.\u003c/p\u003e\n"],["\u003cp\u003eSource applications use \u003ccode\u003easURLQueryItem\u003c/code\u003e to create the URL and \u003ccode\u003eopenURL:options:completionHandler:\u003c/code\u003e to open it, while target applications use \u003ccode\u003eopenURLOptionsFromURL:\u003c/code\u003e to extract the options.\u003c/p\u003e\n"],["\u003cp\u003eKey options include \u003ccode\u003edeviceUniqueID\u003c/code\u003e (required), \u003ccode\u003edeviceFriendlyName\u003c/code\u003e (optional), and \u003ccode\u003esessionID\u003c/code\u003e (optional for joining existing or starting new sessions).\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize these options with \u003ccode\u003estartSessionWithOpenURLOptions:sessionOptions:\u003c/code\u003e to initiate or join Cast sessions seamlessly.\u003c/p\u003e\n"]]],["The GCKOpenURLOptions class manages options for Cast-enabled apps via deep-link URLs. Source apps encode Cast options (device ID, optional session ID) into a URL query item using `asURLQueryItem`. The receiving app extracts these options using `openURLOptionsFromURL:`. This class enables the receiver to start or join a Cast session by providing these options to `startSessionWithOpenURLOptions:sessionOptions:`. Key properties include `deviceUniqueID`, `deviceFriendlyName`, and `sessionID`, enabling connection to a specific device or session.\n"],null,["# GCKOpenURLOptions Class\n\n[Instance Methods](#pub-methods) \\| [Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGCKOpenURLOptions Class Reference \n\nOverview\n--------\n\nAn object representing options that can be passed to a Cast-enabled application via a deep-link URL.\n\nThe source app encodes the Cast-specific options (including the unique ID of the device to cast to, and optionally the session ID of a specific Cast session to join) in a query parameter of the application URL using [asURLQueryItem (GCKOpenURLOptions)](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#aed1ec924900e9ce476887abf06cfc588 \"Converts the options into a URL query item. \"), and then opens the URL using UIApplication's `-[openURL:options:completionHandler:]` method. The target app extracts the Cast-specific options from the URL it receives in its UIApplicationDelegate's `-[application:openURL:options:]` method by calling [openURLOptionsFromURL: (GCKOpenURLOptions)](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#af755ffd517e47ae816884a564245103a \"Extracts the Cast-specific options from the specified URL. \"). It then starts or joins a Cast session by passing these options to [startSessionWithOpenURLOptions:sessionOptions: (GCKSessionManager)](/cast/docs/reference/ios/interface_g_c_k_session_manager#a77bf30ff4579f7c101815d2b2250dc12 \"Attempts to join or start a session with options that were supplied to the UIApplicationDelegate::app...\").\n\nSince\n: 4.0\n\nInherits NSObject, \\\u003cNSCopying\\\u003e, and \\\u003cNSSecureCoding\\\u003e.\n\n|---------------------|-------------------------------------------------------------------------------------------------------------------|\n| Instance Method Summary ----------------------- ||\n| (NSURLQueryItem \\*) | - [asURLQueryItem](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#aed1ec924900e9ce476887abf06cfc588) |\n| | Converts the options into a URL query item. [More...](#aed1ec924900e9ce476887abf06cfc588) |\n| ||\n\n|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (nullable [GCKOpenURLOptions](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options) \\*) | + [openURLOptionsFromURL:](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#af755ffd517e47ae816884a564245103a) |\n| | Extracts the Cast-specific options from the specified URL. [More...](#af755ffd517e47ae816884a564245103a) |\n| ||\n\n|-------------|---------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| NSString \\* | [deviceUniqueID](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#a668da1e22bb4f6cc5920525f03d0ff79) |\n| | The unique ID of the device to connect to. [More...](#a668da1e22bb4f6cc5920525f03d0ff79) |\n| ||\n| NSString \\* | [deviceFriendlyName](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#a54a1b390b84b29d13798270382ccb3cb) |\n| | The friendly name of the device to connect to. [More...](#a54a1b390b84b29d13798270382ccb3cb) |\n| ||\n| NSString \\* | [sessionID](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options#ab797a623e3efe345d25caa3e83046822) |\n| | The session ID of the Cast session to join. [More...](#ab797a623e3efe345d25caa3e83046822) |\n| ||\n\nMethod Detail\n-------------\n\n|-------------------------------------------------------------------------------------------------------------------------|---|------------|-------|---|\n| + (nullable [GCKOpenURLOptions](/cast/docs/reference/ios/interface_g_c_k_open_u_r_l_options) \\*) openURLOptionsFromURL: | | (NSURL \\*) | *url* | |\n\nExtracts the Cast-specific options from the specified URL.\n\nReturns\n: The extracted options, or `nil` if the URL did not contain any Cast-specific options. \n\n|--------------------------------------|---|---|---|\n| - (NSURLQueryItem \\*) asURLQueryItem | | | |\n\nConverts the options into a URL query item.\n\nReturns\n: The options as an NSURLQueryItem.\n\nProperty Detail\n---------------\n\n|---------------------------------------------------------------------|------------------------|\n| |-------------------------------| | - (NSString\\*) deviceUniqueID | | readwritenonatomiccopy |\n\nThe unique ID of the device to connect to.\n\nRequired. \n\n|-----------------------------------------------------------------------------|------------------------|\n| |-----------------------------------| | - (NSString\\*) deviceFriendlyName | | readwritenonatomiccopy |\n\nThe friendly name of the device to connect to.\n\nOptional. This value is not used by the GoogleCast framework, but may be of interest to the receiving application. \n\n|-----------------------------------------------------------|------------------------|\n| |--------------------------| | - (NSString\\*) sessionID | | readwritenonatomiccopy |\n\nThe session ID of the Cast session to join.\n\nOptional. A value of `nil` indicates that any currently active session should be joined, or if there is none, that a new one should be created."]]