SCLFlicManager Class Reference

Inherits from NSObject
Declared in SCLFlicPoicManager.h

Overview

@class SCLFlicManager

This singleton class is required in order to perform any bluetooth LE communication with the Flic/Poic . You need to use this in order to scan for, and discover, new buttons. The object will keep track of all the buttons 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 call the class configuration method on every app boot and averything will be restored as it should. Once the manager has been restored you can collect the associated Flic/Poic 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/Poic related events. See the definition of the SCLFlicManagerDelegate to see what callbacks are available.

Declared In

SCLFlicPoicManager.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, scanned, or 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 every application restoration when the manager sends the flicManagerDidRestoreState callback. See the definition of the SCLFlicButtonDelegate to see what callbacks are available.

Declared In

SCLFlicPoicManager.h

  bluetoothState

@property bluetoothState

@property (nonatomic, readonly) SCLFlicManagerBluetoothState bluetoothState

Discussion

The current bluetoothState of the manager. A bluetoothDidChangeState event will be generated on the SCLFlicManagerDelegate whenever this state has changed. When the 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

SCLFlicPoicManager.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/Poic can be made.

Declared In

SCLFlicPoicManager.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

SCLFlicPoicManager.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 configure the manager. This will initiate a SCLFlicManager and do the proper preparation needed in order to start the bluetooth communication with flic buttons. Using more than one manager in the same application is not supported, which is why we decided to go with the singleton approach.

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, unless you have already set the defaultButtonDelegate, it is recommended that you call knownButtons: in order to collect all the button objects and re-set their delegate.

Declared In

SCLFlicPoicManager.h

– startScan

@method startScan:

- (void)startScan

Discussion

Starts a scan for buttons. Each time a new button is found the manager will call the didDiscoverButton:withRSSI: delegate method. Starting a scan will have no effect if the device does not have bluetooth turned on and the manager is in the proper state. To be sure you can check the SCLFlicManager’s bluetoothState property first. It is recommended that you do not scan for buttons during long periods of time. Background scanning is also quite restricted on iOS so that is also not recommended.

Declared In

SCLFlicPoicManager.h

– stopScan

@method stopScan:

- (NSUInteger)stopScan

Return Value

The number of Poics discovered in total. This includes both public and private Poics. A discovery callback will not be sent if the Poic is private, but it might still be useful to know if there are any Poics around, hence the return parameter.

Discussion

Stopps the current scan. If the manager is not scanning when this call is made then nothing will happen.

Declared In

SCLFlicPoicManager.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 discovered by the manager and not manually been forgotten/removed.

Declared In

SCLFlicPoicManager.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 button from the manager and clear the SCLFlicButton instance. If the button 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. Only after doing this will you be able to discover the button again when doing a new scan.

Declared In

SCLFlicPoicManager.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/Poic until you call enable</enable.

Declared In

SCLFlicPoicManager.h

– enable

@method enable

- (void)enable

Discussion

This will enable the bluetooth communication after it has previously been disabled.

Declared In

SCLFlicPoicManager.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 a Flic button to assign to this App.

Declared In

SCLFlicPoicManager.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

SCLFlicPoicManager.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 at all times.

Declared In

SCLFlicPoicManager.h