GNSBeaconStrategy 类
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
此类继承 NSObject。
+ (instancetype) strategy |
|
|
|
返回自定义策略。您可以在 paramsBlock
中设置任何可选属性。
还可以扫描附近的 iBeacon。
默认值为 YES
。扫描 iBeacon 会在 iOS 中触发位置信息权限对话框,因此如果您不想扫描 iBeacon,则应将此项设置为 NO
。
- (BOOL) allowInBackground |
|
readnonatomicassign |
当应用在后台运行时,尝试扫描信标。
默认值为 NO
。
- (BOOL) lowPowerPreferred |
|
readnonatomicassign |
低功耗模式仅在扫描 Eddystone 信标时可用;当包含 iBeacon 时,系统会忽略低功耗模式。
如果您希望缩短延迟扫描,并增加电池费用,请关闭低功耗模式。
默认值为 YES
。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-13。
[null,null,["最后更新时间 (UTC):2025-08-13。"],[[["\u003cp\u003eThe \u003ccode\u003eGNSBeaconStrategy\u003c/code\u003e class defines the strategy used to scan for nearby beacons, including iBeacons and Eddystone beacons.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for creating default and custom strategies, allowing control over scan behavior like background scanning and power usage.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eincludeIBeacons\u003c/code\u003e property determines whether to scan for iBeacons alongside Eddystone beacons, requiring location permissions if enabled.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eallowInBackground\u003c/code\u003e enables scanning while the app is in the background, while \u003ccode\u003elowPowerPreferred\u003c/code\u003e prioritizes lower battery consumption when scanning for Eddystone beacons only.\u003c/p\u003e\n"]]],[],null,["# GNSBeaconStrategy Class\n\n[Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGNSBeaconStrategy Class Reference \n\nOverview\n--------\n\nThe strategy to use to scan for beacons.\n\nInherits NSObject.\n\n|----------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (instancetype) | + [strategy](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#adb20ee9c949a83bb6b40f298afc8d18c) |\n| | Returns the default strategy, which uses the default values for all properties. [More...](#adb20ee9c949a83bb6b40f298afc8d18c) |\n| ||\n| (instancetype) | + [strategyWithParamsBlock:](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#ae4369cbfc0033043904d608a941ffab9) |\n| | Returns a custom strategy. You can set any of the optional properties in `paramsBlock`. [More...](#ae4369cbfc0033043904d608a941ffab9) |\n| ||\n\n|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| BOOL | [includeIBeacons](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a760bff5c7b04f6aca45f5eb1b00f64d6) |\n| | Scan also for nearby iBeacons. [More...](#a760bff5c7b04f6aca45f5eb1b00f64d6) |\n| ||\n| BOOL | [allowInBackground](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a78563e40e80e958da3381600240063d7) |\n| | Try to scan for beacons when the app is in the background. [More...](#a78563e40e80e958da3381600240063d7) |\n| ||\n| BOOL | [lowPowerPreferred](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a24d256ff2f7cf627b539534bb0a1241d) |\n| | Low power mode is available when scanning for Eddystone beacons only; it is ignored when iBeacons are included. [More...](#a24d256ff2f7cf627b539534bb0a1241d) |\n| ||\n\nMethod Detail\n-------------\n\n|---------------------------|---|---|---|\n| + (instancetype) strategy | | | |\n\nReturns the default strategy, which uses the default values for all properties. \n\n|-------------------------------------------|---|-----------------------------------------------------------------------------------------------------------------|---------------|---|\n| + (instancetype) strategyWithParamsBlock: | | (void(\\^)([GNSBeaconStrategyParams](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy_params) \\*)) | *paramsBlock* | |\n\nReturns a custom strategy. You can set any of the optional properties in `paramsBlock`.\n\nProperty Detail\n---------------\n\n|-----------------------------------------------------------|---------------------|\n| |--------------------------| | - (BOOL) includeIBeacons | | readnonatomicassign |\n\nScan also for nearby iBeacons.\n\nThe default is `YES`. Scanning for iBeacons triggers a location permission dialog from iOS, so you should set this to `NO` if you don't want to scan for iBeacons. \n\n|---------------------------------------------------------------|---------------------|\n| |----------------------------| | - (BOOL) allowInBackground | | readnonatomicassign |\n\nTry to scan for beacons when the app is in the background.\n\nThe default is `NO`. \n\n|---------------------------------------------------------------|---------------------|\n| |----------------------------| | - (BOOL) lowPowerPreferred | | readnonatomicassign |\n\nLow power mode is available when scanning for Eddystone beacons only; it is ignored when iBeacons are included.\n\nTurn off low power mode if you prefer lower latency scanning, at a higher battery cost.\n\nThe default is `YES`."]]