SWRLSwirl Class Reference

Inherits from NSObject
Declared in SWRLSwirl.h
SWRLSwirl.m

Overview

The Swirl class is the main entry point into the Swirl proximity sdk for delivery of proximity and content events to your app.

You use a singleton instance of this class to start: and stop proximity detection and delivery of proximity events. It supports a multi-delegate interface so you can add one or many delegate objects to recieve callbacks from any of the protocols broadcast to the mult-delegate bus.

System Information

  status

The current system status

@property (nonatomic, readonly) SWRLStatus status

Declared In

SWRLSwirl.h

  version

The current version of the framework.

@property (nonatomic, readonly) NSString *version

Declared In

SWRLSwirl.h

  error

The last error reported.

@property (nonatomic, readonly) NSError *error

Declared In

SWRLSwirl.h

  location

The frameworks currently maintained CLLocation

@property (nonatomic, readonly) CLLocation *location

Declared In

SWRLSwirl.h

User Information

  userKey

A NSUUID generated for this device.

@property (nonatomic, readonly) NSString *userKey

Declared In

SWRLSwirl.h

  userInfo

A dictionary of property values that are associated with this device/user.

@property (nonatomic) NSDictionary *userInfo

Declared In

SWRLSwirl.h

  deviceToken

Device token for remote push notification registration.

@property (nonatomic) NSData *deviceToken

Declared In

SWRLSwirl.h

Managing Delegates

– addDelegate:

Add a delegate to the internal delegate bus

- (void)addDelegate:(id)delegate

Parameters

delegate

The object to receive delegate callbacks. This parameter must not be nil.

Discussion

Delegates are added to the internal multicast delegate bus and can receive messages from any of the listed protocols (see x). Delegates added via this method are added using the main queue. This function simply calls addDelegate:queue: with the result of dispatch_get_main_queue() as the queue argument. If the existing delegate has already been added, this function takes no action.

Declared In

SWRLSwirl.h

– addDelegate:queue:

Add a delegate to the internal delegate bus, specifying a queue.

- (void)addDelegate:(id)delegate queue:(dispatch_queue_t)queue

Parameters

delegate

The object to receive delegate callbacks. This parameter must not be nil.

queue

The GCD dispatch queue on which messages should be delivered. This parameter must not be nil.

Discussion

Delegates are added to the internal multicast delegate bus and can receive messages from any of the listed protocols (see x). All messages dispatched to this delegate will be delivered on the queue specified. If the existing delegate has already been added, this function takes no action.

Declared In

SWRLSwirl.h

– removeDelegate:

Remove a delegate that had been previously added via addDelegate:.

- (void)removeDelegate:(id)delegate

Parameters

delegate

The object to receive delegate callbacks. This paramter must not be nil.

Discussion

If the delegate is not present, this method does nothing.

Declared In

SWRLSwirl.h

– findDelegateOfClass:

Find a delegate given a class.

- (id)findDelegateOfClass:(Class)aclass

Parameters

aclass

The class of delegate to find.

Return Value

The delegate if found, or nil.

Discussion

Finds the first delegate of a given class and returns it if found, otherwise it returns nil.

Declared In

SWRLSwirl.h

Managing Lifecyle

– start:

Starts the sdk and all loaded managers

- (void)start:(nullable NSDictionary *)options

Parameters

options

all of the startup options (see x)

Declared In

SWRLSwirl.h

– stop

Stops the sdk

- (void)stop

Discussion

This method is not typically used unless you want to stop all monitoring. If this is called all monitoring will stop, including background monitoring. Your application will no longer receive any notifications for proximity events and will not be restarted in the background by the operating system.

Declared In

SWRLSwirl.h

– reset

Removes all locally stored data and state. If the sdk is currently running, it will call stop first. After calling this function, the sdk will be in a stopped state.

- (void)reset

Discussion

This method is not typically used. It is provided for testing or to be used if you need to completely remove any state stored locally on the device when a user opts-out.

Declared In

SWRLSwirl.h

Passing Information to Swirl

– postObject:

Post an object to the internal message bus

- (void)postObject:(id)object

Parameters

object

the object to post

Discussion

Posting an object is a convenient short hand to calling postMessage:withObject:. The method invoked on members of the internal bus is on{[[object class] name]}:object. This method is used primarily to post UILocalNotifications to Swirl from applicaiton:didReceiveLocalNotification:, or to post CLLocation objects if you are running Swirl in a manual location mode (when the framework does not maintain its own CLLocationManager).

Declared In

SWRLSwirl.h

– logEvent:data:

Log event to the log stream.

- (void)logEvent:(NSString *)event data:(NSString *)data

Parameters

event

The event name (see the list of known events)

data

The data for event (see the list of events)

Declared In

SWRLSwirl.h

– streamMessage:

Stream custom message to the live event stream. Flushes any pending events at the same time.

- (void)streamMessage:(NSDictionary *)msg

Parameters

msg

Data to stream (JSON encodable)

Declared In

SWRLSwirl.h

– flushEvents

Flush queued events. Use with caution to avoid uncessary client-server traffic. Outside of testing scenarios, this is generally not needed as the SDK will optimize and flush events at the appropriate time.

- (void)flushEvents

Declared In

SWRLSwirl.h

+ setLogLevel:filter:

Control the log level. Default level is @“W”

+ (void)setLogLevel:(NSString *)level filter:(nullable NSString *)filter

Parameters

level

@“E”, @“W”, @“I” for error, warning or info levels, anything else will disable.

filter

nil or comma separated list of modules to include

Declared In

SWRLSwirl.h

+ shared

Swirl is a singleton. You use shared to get access to the shared instance.

+ (instancetype)shared

Declared In

SWRLSwirl.h

+ with:

Advanced: This initalizes the singleton with non-default array of manager classes. Afterwards can access Swirl using the normal accessor [Swirl shared]. Default classes: SWRLVisitManager, SWRLBeaconManager, SWRLRegionManager, SWRLWifiManager, SWRLIBeaconScanner, SWRLBluetoothScanner

+ (instancetype)with:(NSArray<Class> *)classes

Parameters

classes

An array of class objects to initialize the managers/observers can be empty

Declared In

SWRLSwirl.h