Inherits from NSObject
Declared in NAPlatform.h

Overview

NAPlatform is the main class for the NewAer Proximity Platform. It provides methods for starting and stopping scanning, and starting and stopping advertising. NAPlatform is intended to be used as a singleton. You must first initialized the platform before you can access the singleton. Use [NAPlatform initializeWithApplicationId:packageName:delegate:] and then [NAPlatform sharedNAPlatform].

Applications can register a delegate to receive notifications of when a device is found or lost, or if its health changes.

Tasks

Other Methods

  •   delegate

    Assign a delegate to receive NAPlatformDelegate messages.

    property
  • + isInitialized

    Determine if NAPlatform has been initialized yet

  • + setLogLevel:classes:logger:

    Set logging level for the SDK and provide a callback function to receive log messages NALOGLEVEL_DEBUG is only available in debug builds of the SDK.

  • + initializeWithApplicationId:packageName:delegate:

    Initialize NAPlatform with your developer application ID and delegate. You must initialize the platform before you can access [NAPlatform sharedNAPlatform].

  • + sharedNAPlatform

    NAPlatform is a singleton and this is the only way to access the instance.

  • – registerBeaconIds:

    Register iBeacon IDs that this application is compatible with. Register additional iBeacon IDs before you begin scanning to ensure that you will detect devices with those IDs. If you only need to scan for devices matching your registered application ID, you don’t need to call this function.

  • – allowBackground:

    Enable/disable background scanning. This allows you to control if the NewAer SDK will process events when your application is in the background. If you disable background scanning, your application will use less power.

  • – enableRanging:

    Enable support for ranging. This will allow you to receive device updates more frequently when you are scanning. When state = NO (default) you will receive a device update no more often than once every 30 seconds. When state = YES you will receive a device update as often as the hardware supports, typically around once a second.

  • – includeRemoteDevices:

    Include remotely discovered devices. This method tells the SDK to use the NewAer Proximity Server to compare local observations made by each device running the SDK with others. Devices will be found even if they cannot always be seen directly. The NewAer Proximity server identifies shared observations, such as a Beacon, a WiFi access point, or another NewAer enabled device. Those shared observations are used to make indirect proximity connections.

Scanning

Advertising

Messaging

  • – sendMessage:to:

    Queues a message to be sent to a device ID. The device ID need not be visible currently and may come into range in the future. The message send request does not timeout and only one message may be queued at a time. Calling this method a second time overwrites the first message. Only peer devices of scan type NATYPE_NEWAER can receive messages. When you stop scanning, all queued messages are discarded.

  • – releaseDevice:

    Releases a device identified by deviceId from the scanning cache. Use this to get new peer info on the next scan.

Platform information

  • – getMyDeviceId

    Gets the deviceId for this device for the corresponding NADeviceType

  • + launchedWithLocation

    Indicates whether the application was launched as a result of a beacon based geofence. Call immediately after initializing NAPlatform.

  • – handleWake

    This method is used to send a wakeup event to NAPlatform. This event may cause scanning or advertising to be restarted. This method is typically used to enable background scanning to occur when your application awakes due to an iOS background event such as: background refresh, server push, or regular location change. NAPlatform automatically handles iOS background events due to: bluetooth central/peripheral and significant location changes. Call this event from your app delegate for:

      UIApplication application:performFetchWithCompletionHandler:,
      UIApplication application:didReceiveRemoteNotification:fetchCompletionHandler:,
      or from your core location manager delegate for: CoreLocation locationManager:didUpdateLocations:
    

  • – handleTerminate

    This method is used to ensure that the NewAer SDK is put into a known state when your application is killed by the user. You need to call this method from your AppDelegate applicationWillTerminate:(UIApplication *)application method. If you do not call this method, your app may not be correctly resurrected when encountering an iBeacon.

Properties

delegate

Assign a delegate to receive NAPlatformDelegate messages.

@property (assign) NSObject<NAPlatformDelegate> *delegate

Declared In

NAPlatform.h

Class Methods

initializeWithApplicationId:packageName:delegate:

Initialize NAPlatform with your developer application ID and delegate. You must initialize the platform before you can access [NAPlatform sharedNAPlatform].

+ (BOOL)initializeWithApplicationId:(NSString *)applicationId packageName:(NSString *)packageName delegate:(NSObject<NAPlatformDelegate> *)delegate

Parameters

applicationId

A string containing your NewAer application ID

packageName

A string containing your NewAer package name/bundle identifier

delegate

The delegate that implements the NAPlatformDelegate protocol

Discussion

You will not be able to access functions of NAPlatform until you have set the application ID. The application ID is not checked immediately so the response reflects the most recent ID that was set.

To obtain an application ID, visit newaer.com and login to the developer portal. You will need your application’s bundle identifier (ex: “com.newaer.newaer-sdk-example”) to create an application ID.

Declared In

NAPlatform.h

isInitialized

Determine if NAPlatform has been initialized yet

+ (BOOL)isInitialized

Declared In

NAPlatform.h

launchedWithLocation

Indicates whether the application was launched as a result of a beacon based geofence. Call immediately after initializing NAPlatform.

+ (BOOL)launchedWithLocation

Return Value

YES/NO

Declared In

NAPlatform.h

setLogLevel:classes:logger:

Set logging level for the SDK and provide a callback function to receive log messages NALOGLEVEL_DEBUG is only available in debug builds of the SDK.

+ (void)setLogLevel:(NALogLevel)level classes:(NSArray *)classes logger:(void ( ^ ) ( NALogLevel level , NSString *message ))logger

Parameters

level

Indicate what level of activity to log. Messages lower than this level will not be output.

classes

An NSArray of NSString objects with the class names to output log messages for. Use nil to display all classes.

logger

A block that will be called each time a log message is available

Discussion

typedef enum {
  NALOGLEVEL_DEBUG = 0,
  NALOGLEVEL_INFO = 1,
  NALOGLEVEL_ERROR = 2
} NALogLevel;

Declared In

NAPlatform.h

sharedNAPlatform

NAPlatform is a singleton and this is the only way to access the instance.

+ (NAPlatform *)sharedNAPlatform

Declared In

NAPlatform.h

Instance Methods

allowBackground:

Enable/disable background scanning. This allows you to control if the NewAer SDK will process events when your application is in the background. If you disable background scanning, your application will use less power.

- (void)allowBackground:(BOOL)state

Parameters

state

BOOL YES = allow background scanning [default]; NO = disallow background scanning

Discussion

By default, background scanning is enabled and tuned to use as little battery as possible. The regular background scanning mode will detect most devices that are unlocked.

An advanced background scanning mode is available that can help detect locked devices, but requires significant synchronization between your application and the NewAer SDK and is beyond the scope of this documentation. Please request the Advanced Background Scanning application note from [email protected] if you need this functionality.

Declared In

NAPlatform.h

enableRanging:

Enable support for ranging. This will allow you to receive device updates more frequently when you are scanning. When state = NO (default) you will receive a device update no more often than once every 30 seconds. When state = YES you will receive a device update as often as the hardware supports, typically around once a second.

- (void)enableRanging:(BOOL)state

Parameters

state

BOOL YES = enable ranging; NO = disable ranging (default)

Discussion

Note that enabling ranging consumes significantly more power than if it is disabled. It should only be used when your device is in the foreground and has a need for frequent device updates. You might use this mode if you need to track the movement of a device and want to know when it goes from NAPROXIMITY_FAR to NAPROXIMITY_NEAR.

Declared In

NAPlatform.h

getMyDeviceId

Gets the deviceId for this device for the corresponding NADeviceType

- (NSString *)getMyDeviceId

Return Value

A deviceId string that can be used to uniquely identify your application.

Declared In

NAPlatform.h

handleTerminate

This method is used to ensure that the NewAer SDK is put into a known state when your application is killed by the user. You need to call this method from your AppDelegate applicationWillTerminate:(UIApplication *)application method. If you do not call this method, your app may not be correctly resurrected when encountering an iBeacon.

- (void)handleTerminate

Declared In

NAPlatform.h

handleWake

This method is used to send a wakeup event to NAPlatform. This event may cause scanning or advertising to be restarted. This method is typically used to enable background scanning to occur when your application awakes due to an iOS background event such as: background refresh, server push, or regular location change. NAPlatform automatically handles iOS background events due to: bluetooth central/peripheral and significant location changes. Call this event from your app delegate for:

  UIApplication application:performFetchWithCompletionHandler:,
  UIApplication application:didReceiveRemoteNotification:fetchCompletionHandler:,
  or from your core location manager delegate for: CoreLocation locationManager:didUpdateLocations:

- (void)handleWake

Declared In

NAPlatform.h

includeRemoteDevices:

Include remotely discovered devices. This method tells the SDK to use the NewAer Proximity Server to compare local observations made by each device running the SDK with others. Devices will be found even if they cannot always be seen directly. The NewAer Proximity server identifies shared observations, such as a Beacon, a WiFi access point, or another NewAer enabled device. Those shared observations are used to make indirect proximity connections.

- (void)includeRemoteDevices:(BOOL)state

Parameters

state

BOOL YES = enable remove devices; NO = disable remote devices (default)

Declared In

NAPlatform.h

registerBeaconIds:

Register iBeacon IDs that this application is compatible with. Register additional iBeacon IDs before you begin scanning to ensure that you will detect devices with those IDs. If you only need to scan for devices matching your registered application ID, you don’t need to call this function.

- (BOOL)registerBeaconIds:(NSArray *)beaconIds

Parameters

beaconIds

An NSArray containing beaconIds to register, For example: @[ @“ac3bd3f7-7d1d-4132-94f2-f9ef0594eeb5”, …]

Declared In

NAPlatform.h

releaseDevice:

Releases a device identified by deviceId from the scanning cache. Use this to get new peer info on the next scan.

- (void)releaseDevice:(NSString *)deviceId

Parameters

deviceId

Which device ID to send the message to. This value is typically obtained from an NADevice object.

Declared In

NAPlatform.h

sendMessage:to:

Queues a message to be sent to a device ID. The device ID need not be visible currently and may come into range in the future. The message send request does not timeout and only one message may be queued at a time. Calling this method a second time overwrites the first message. Only peer devices of scan type NATYPE_NEWAER can receive messages. When you stop scanning, all queued messages are discarded.

- (BOOL)sendMessage:(NAMessage *)message to:(NSString *)deviceId

Parameters

message

The message to send to the device.

deviceId

Which device ID to send the message to. This value is typically obtained from an NADevice object.

Discussion

See the [NAPlatformDelegate platformDidSendMessageToDevice:withStatus:] delegate to be informed of message status.

Declared In

NAPlatform.h

startAdvertisingWithDeviceTypes:name:

Start advertising for the specified device types. The only device types that currently support advertising are NATYPE_NEWAER and NATYPE_BEACON (iOS only).

- (void)startAdvertisingWithDeviceTypes:(NSArray *)deviceTypes name:(NSString *)name

Parameters

deviceTypes

Which device types to enable advertising for. Pass an NSArray of NSNumber objects. Each NSNumber object should take the value of one of the NADeviceType eunmerated values. Pass nil to start advertising on all available device types.

name

A name that will be used when advertising. If nil, the current operating system provided device name is used.

Discussion

The [NAPlatformDelegate platformAdvertiseFailed:] delegate will be called if there was a problem starting advertising for any device type.

The [NAPlatformDelegate platformDidStartAdvertise:] delegate will be called if the advertising was started successfully.

Note that advertising with NATYPE_BEACON will create a virtual iBeacon with a proximityUUID of your Application ID, a major ID of 0, and a minor ID of 0. This advertisement occurs for 5 seconds every time the application is brought to the foreground. The advertisement also occurs every 3 minutes for 5 seconds. It is primarily intended to resurrect your application running on another iOS device nearby. For more details, please refer to the NewAer Advanced Background Mode Application Note.

Declared In

NAPlatform.h

startScanWithDeviceTypes:

Starts scanning for a specific scan family.

- (void)startScanWithDeviceTypes:(NSArray *)deviceTypes

Parameters

deviceTypes

Which device types to enable scanning for. Pass an NSArray of NSNumber objects. Each NSNumber object should take the value of one of the NADeviceType eunmerated values.

Discussion

The [NAPlatformDelegate platformScanFailed:status:] delegate will be called if there was a problem starting scanning for any device type.

The [NAPlatformDelegate platformDidStartScan:] delegate will be called if the scan was started successfully.

The [NAPlatformDelegate platformDidCompleteOneScan:] delegate will be called each time a round of scanning completes. Use this message to determine when to stop scanning or when to send results to another module for processing.

Once the scan has started, the [NAPlatformDelegate platformDidFindDevice:] and [NAPlatformDelegate platformDidLoseDevice:] delegates will be called each time a device is found or lost.

(iOS Only) Scanning is only intended to be used while the application is in the foreground. If the application is in the background or the device is locked, certain types of scans may be disabled or have degraded performance.

Declared In

NAPlatform.h

stopAdvertisingWithDeviceTypes:

Stops advertising for specific device types. The [NAPlatformDelegate platformDidStopAdvertise:] delegate will be called if the advertise was stopped successfully.

- (void)stopAdvertisingWithDeviceTypes:(NSArray *)deviceTypes

Parameters

deviceTypes

Which scan types to stop advertising for. Pass an NSArray of NSNumber objects. Each NSNumber object should take the value of one of the NADeviceType eunmerated values. Pass nil for all device types.

Declared In

NAPlatform.h

stopScanWithDeviceTypes:

Stops scanning for specific device types.

- (void)stopScanWithDeviceTypes:(NSArray *)deviceTypes

Parameters

deviceTypes

Which device types to disable scanning for. Pass an NSArray of NSNumber objects. Each NSNumber object should take the value of one of the NADeviceType eunmerated values. Pass nil to stop scanning for all device types.

Discussion

The [NAPlatformDelegate platformDidStopScan:] delegate will be called when the scan was stopped successfully.

Declared In

NAPlatform.h