GNSStrategy Class

GNSStrategy Class Reference

Overview

The strategy to use to detect nearby devices.

Inherits NSObject.

Class Method Summary

(instancetype) + strategy
 Returns the default strategy, which uses the default values for all properties. More...
 
(instancetype) + strategyWithParamsBlock:
 Returns a custom strategy. You can set any of the optional properties in paramsBlock. More...
 

Property Summary

GNSDiscoveryMode discoveryMode
 For nearby device discovery, one device must broadcast a pairing code and the other device must scan for pairing codes. More...
 
GNSDiscoveryMediums discoveryMediums
 Controls which mediums to use to broadcast and scan pairing codes when discovering nearby devices. More...
 
BOOL allowInBackground
 Try to use the discovery strategy when the app is in the background. More...
 

Method Detail

+ (instancetype) strategy

Returns the default strategy, which uses the default values for all properties.

+ (instancetype) strategyWithParamsBlock: (void(^)(GNSStrategyParams *))  paramsBlock

Returns a custom strategy. You can set any of the optional properties in paramsBlock.

Property Detail

- (GNSDiscoveryMode) discoveryMode
readnonatomicassign

For nearby device discovery, one device must broadcast a pairing code and the other device must scan for pairing codes.

Because there is no way to negotiate beforehand, the default is for all devices to both broadcast and scan.

This property lets you customize this behavior, restricting your app to either broadcast or scan. For example, consider a mobile app that communicates with a set-top box. If the set-top box is programmed to broadcast a pairing code, the mobile app could be set to scan only, to improve latency.

The default is kGNSDiscoveryModeDefault.

- (GNSDiscoveryMediums) discoveryMediums
readnonatomicassign

Controls which mediums to use to broadcast and scan pairing codes when discovering nearby devices.

See discoveryMode for more details about device discovery.

The default is kGNSDiscoveryMediumsDefault.

- (BOOL) allowInBackground
readnonatomicassign

Try to use the discovery strategy when the app is in the background.

Note that not all strategies will be permitted to run in the background. You can request this here, and depending on other settings and circumstances, the strategy might be allowed to continue in the background. Currently only BLE scans/broadcasts are supported.

The default is NO.