SCLFlicManager Class Reference

Inherits from NSObject
Declared in SCLFlicManager.h

Overview

@class SCLFlicManager

An instance of this class is required in order to perform any bluetooth LE communication with the flic. The object will keep track of all the flics that are associated to the specific iOS device. It is important to mention that the SCLFlicManager does not support the regular state preservation and restoration protocol for view controllers, meaning that it does not support NSCoding. Instead, all of the state preservation will be taken cared of for you by the manager. Simply reinstantiate it using the initWithDelegate:appID:appSecret:andRestoreState: method and collect the associated flic objects using the knownButtons: method.

  delegate

@property delegate

@property (weak, nonatomic, nullable) id<SCLFlicManagerDelegate> delegate

Discussion

The delegate object that will receive all the flic related events. See the definition of the SCLFlicManagerDelegate to see what callbacks are available.

Declared In

SCLFlicManager.h

  defaultButtonDelegate

@property defaultButtonDelegate

@property (weak, nonatomic, nullable) id<SCLFlicButtonDelegate> defaultButtonDelegate

Discussion

The default delegate that will be assigned to all buttons both when they are grabbed, but also during state restoration. This is not required since the button delegates can be set manually. If you decide to set them manually then you have to also remember to set them on on every application restoration when the manager sends the flicManagerDidRestoreState callback.

Declared In

SCLFlicManager.h

  bluetoothState

@property bluetoothState

@property (nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState

Discussion

The current bluetoothState of the flic manager. A bluetoothDidChangeState event will be generated on the SCLFlicManagerDelegate whenever this state has changed. When the flic manager is initialized the state will be SCLFlicManagerBluetoothStateUnknown by default. You will not be able to do any bluetooth related tasks until the manager properly changes to SCLFlicManagerBluetoothStateOn.

Declared In

SCLFlicManager.h

  enabled

@property enabled

@property (readonly, getter=isEnabled) BOOL enabled

Discussion

This is a flag that lets you know if the manager is enabled for Bluetooth LE communication. This can be toggled on/off using the enable and disable. When This property is set to NO, then no Bluetooth LE communication will be allowed. This means that no communication with a flic can be made.

Declared In

SCLFlicManager.h

+ sharedManager

@method sharedManager

+ (instancetype _Nullable)sharedManager

Discussion

Use this to access the manager singleton. This will only work if a call to configureWithDelegate:appID:appSecret:backgroundExecution: has been made once this app session, otherwise nil will be returned.

Declared In

SCLFlicManager.h

+ configureWithDelegate:defaultButtonDelegate:appID:appSecret:backgroundExecution:

@method configureWithDelegate:defaultButtonDelegate:appID:appSecret:backgroundExecution:

+ (instancetype _Nullable)configureWithDelegate:(id<SCLFlicManagerDelegate> _Nullable)delegate defaultButtonDelegate:(id<SCLFlicButtonDelegate> _Nullable)buttonDelegate appID:(NSString *_Nonnull)appID appSecret:(NSString *_Nonnull)appSecret backgroundExecution:(BOOL)bExecution

Parameters

delegate

The delegate that all callbacks will be sent to.

buttonDelegate

This delegate will automatically be set to new buttons and old buttons on app restoration.

appID

This is the App-ID string that the developer is required to have in order to use the fliclib framework.

appSecret

This is the App-Secret string that the developer is required to have in order to use the fliclib framework.

bExecution

Flag that specifies if want to configure the Flic manager to support background execution. If YES, then you also have to check the “Uses Bluetooth LE accessories” option under your projects Background Modes settings.

Discussion

The initialization call to use when you want to create a manager. This will initiate a SCLFlicManager and do the proper preparation needed in order to start the bluetooth communication with flic buttons. The BOOL restore included in the initialization call decides whether a brand new manager will be created or if it should be created and restored to the last known state of the most previous manager created by the same app. If you choose to create a new manager then any old manager (if existing) will be irreversibly cleared. Using more than one manager in the same application is not supported.

When choosing the restore option all settings on the manager will be restored. This will also recreate all SCLFlicButtons that had previously been used with this manager unless they had been manually removed using the forgetButton: method. All the flic objects that had a pending connection before will be set to the same state after restoration. When the restoration process is complete the manager will call the flicManagerDidRestoreState: method of its delegate object. At that point it is recommended that you call knownButtons: in order to collect all the flic objects and re-set their delegate.

Declared In

SCLFlicManager.h

– knownButtons

@method knownButtons:

- (NSDictionary<NSUUID*,SCLFlicButton*> *_Nonnull)knownButtons

Return Value

Dictionary containing the SCLFlicButton objects. The keys are of NSUUID type that represent the buttonIdentifier of the SCLFlicButton instance.

Discussion

All buttons that have ever been added to the manager and not manually been forgotten/removed.

Declared In

SCLFlicManager.h

– forgetButton:

@method forgetButton:

- (void)forgetButton:(SCLFlicButton *_Nonnull)button

Parameters

button

The button that you wish to destroy.

Discussion

This will attempt to completely remove the flic button from the manager and clear the SCLFlicButton instance. If the flic is connected when this method is called then it will also be disconnected first. Remember to clear all your references to this particular button instance so that it properly gets cleared from memory.

Declared In

SCLFlicManager.h

– disable

@method disable

- (void)disable

Discussion

This will disable all bluetooth communication and disconnect all currently connected buttons and pending connections. You will not be able to do any communication with a flic until you call enable</enable.

Declared In

SCLFlicManager.h

– enable

@method enable

- (void)enable

Discussion

This will enable the bluetooth communication after it has previously been disabled. It will not however reconnect any buttons, that will have to be handled manually. This is unless you have the flic(s) configured to be in KeepAlive mode, in which case the connect will automatically be sent.

Declared In

SCLFlicManager.h

– grabFlicFromFlicAppWithCallbackUrlScheme:

@method grabFlicFromFlicAppWithCallbackUrlScheme:

- (void)grabFlicFromFlicAppWithCallbackUrlScheme:(NSString *_Nonnull)scheme

Parameters

scheme

This is the callback URL that you have registered in your Plist file and want the Flic app to return the grabbed Flic to. Remember that this is only the scheme name that you have registered, and NOT a full URL.

Discussion

This will launch the Flic app and allow the user to select the Flic button to assign to this App.

Declared In

SCLFlicManager.h

– handleOpenURL:

@method handleOpenURL:

- (BOOL)handleOpenURL:(NSURL *_Nonnull)url

Parameters

url

This is the full url that was returned from the Flic app.

Return Value

If this url can be handled by the flic manager or not.

Discussion

Call this method with the URL returned from the Flic app. A callback will be sent if a button can be created.

Declared In

SCLFlicManager.h

– onLocationChange

@method onLocationChange

- (void)onLocationChange

Discussion

Call this method on significant location changes. This will go through all pending connections and make sure that they are in the proper state. This is needed since we can not rely on Apple to take care of that to 100%.

Declared In

SCLFlicManager.h