SCLFlicButton

@interface SCLFlicButton : NSObject

An instance of this class represents a physical Flic or PbF. All commands will be directly passed to the physical Flic/PbF and any events occurring on the Flic/PbF will be passed along using the specified delegate methods.

  • The delegate object that will receive events related to this particular Flic/PbF.

    Declaration

    Objective-C

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

    Swift

    weak var delegate: SCLFlicButtonDelegate? { get set }
  • The virtual ID of the button. This is the identifier that is recommended to use when identifying the buttons.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nonnull) NSUUID *buttonIdentifier;

    Swift

    var buttonIdentifier: UUID { get }
  • The public key of the button. This in the key that is used to identify the Flic/PbF on our backend.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nonnull) NSString *buttonPublicKey;

    Swift

    var buttonPublicKey: String { get }
  • This property exposes the real mac addres of the Flic/PbF. The returned string is 17 character long on the format “xx:xx:xx:xx:xx:xx”.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nonnull) NSString *macAddress;

    Swift

    var macAddress: String { get }
  • The Bluetooth device name of the Flic/PbF button.

    Declaration

    Objective-C

    @property (strong, readonly, nonnull) NSString *name;

    Swift

    var name: String { get }
  • The actual color of a grabbed Flic button. If for some reason the real color is not available, such as if the button was already grabbed with an earlier version of fliclib, then the color will default to white. Please note that this is only available on Flic buttons that have been grabbed from the Flic App. For PbF buttons this will always be be white.

    Declaration

    Objective-C

    @property (strong, readonly, nonnull) UIColor *color;

    Swift

    var color: UIColor { get }
  • This is the user assigned name of the Flic button that is assigned and displayed in the Flic App. Please note that this is only available on Flic buttons that have been grabbed from the Flic App. For PbF buttons will only be an empty string.

    Declaration

    Objective-C

    @property (strong, readonly, nonnull) NSString *userAssignedName;

    Swift

    var userAssignedName: String { get }
  • The current state of the button.

    Declaration

    Objective-C

    @property (readonly) SCLFlicButtonConnectionState connectionState;

    Swift

    var connectionState: SCLFlicButtonConnectionState { get }
  • Deprecated

    Use mode instead. See SCLFlicButtonModeLowLatency.

    The latency setting for this button. If you set this to YES then you will get lower latency on the click events when your app is in the foreground and the button is connected. As soon as the app leaves the foreground it will be set back to the regular latency setting. Please only use this if you have a very good reason for it, such as if you are designing a foreground game that requires it. Battery consumption will increase with this activated.

    Declaration

    Objective-C

    @property (nonatomic) BOOL lowLatency;

    Swift

    var lowLatency: Bool { get set }
  • This property specifies how the Flic/PbF press events should be handled. You are allowed to change this property any time you want. Take a look at SCLFlicButtonTriggerBehavior to see the options available.

    Declaration

    Objective-C

    @property (nonatomic) SCLFlicButtonTriggerBehavior triggerBehavior;

    Swift

    var triggerBehavior: SCLFlicButtonTriggerBehavior { get set }
  • This property specifies how many times the Flic/PbF has been toggled at any given time. This will register all down events as well as the up events, which means that if you want to know how many times it has been clicked then you have to divide this number by two. Also, this property will always contain the last known registered value, meaning that if the Flic/PbF has been pressed while not being within proximity then the property will of course not be up to date. It will be updated as soon as the Flic/PbF connects the next time. Important notice: Even though this value is represented by an int the internal counter only consists of 3 bytes meaning that the counter will rollover at 0xffffff (16777215). However, it is highly unlikely that anyone will ever reach those numbers. The presscounter will be reset if a factory reset is done on the physical Flic/PbF button.

    Declaration

    Objective-C

    @property (nonatomic, readonly) int pressCount;

    Swift

    var pressCount: Int32 { get }
  • This property lets you know wether the Flic/PbF is ready or not. Only when it is ready will you be able to recieve or send data to it.

    Declaration

    Objective-C

    @property (readonly) BOOL isReady;

    Swift

    var isReady: Bool { get }
  • This property specifies the last known battery status of the Flic/PbF. If the status is Unknown then it may take up to 24h before a correct value is calculated.

    Declaration

    Objective-C

    @property (nonatomic) SCLFlicButtonBatteryStatus batteryStatus;

    Swift

    var batteryStatus: SCLFlicButtonBatteryStatus { get set }
  • This property lets you decide if you want the Flic/PbF button to automatically disconnect after a specified amount of time after each button press. Doing this can reduce the power consumption of the Flic/PbF button and thus extend the battery life, but it may also increase the click latency since the button has to reconnect on each button press. The unit is in seconds and the max value is 511, which represents infinity, or no auto disconnect time. 511 will also be the default value. If you try to set anything above 511 then it will be automatically set to 511 instead. The lowest timeout is 1 second. If a second button press occurs before the timeout of a previous press then the timeout will be extended. We recommend using 10 seconds for use cases where the user only presses the button occasionally and low latency is not critical. Changes to this property will only take effect on the next connect of the button. This means that if you change this while the button is currently connected, then it is not until the next time the button connects that it actually will be applied. Therefore we recommend choosing your value before connecting the button the first time.

    Declaration

    Objective-C

    @property (nonatomic) uint16_t autoDisconnectTime;

    Swift

    var autoDisconnectTime: UInt16 { get set }
  • The mode that the button operates in. Please see the SCLFlicButtonMode enum descriptions to learn more.

    Declaration

    Objective-C

    @property (nonatomic) SCLFlicButtonMode mode;

    Swift

    var mode: SCLFlicButtonMode { get set }
  • Attempts to connect the button. If the Flic/PbF is not available, due to either being out of range or not advertising, then it will be connected once it becomes available since this call will not time out, also called a pending connection. It can be canceled by calling the disconnect method.

    Declaration

    Objective-C

    - (void)connect;

    Swift

    func connect()
  • Disconnect a currently connected Flic/PbF or cancel a pending connection.

    Declaration

    Objective-C

    - (void)disconnect;

    Swift

    func disconnect()
  • Use this method when you want to indicate something to the user by fading the LED. Be mindful with battery usage. Please note that this only works while the button is currently connected and ready.

    Declaration

    Objective-C

    - (void)indicateLED:(SCLFlicButtonLEDIndicateCount)count;

    Swift

    func indicateLED(_ count: SCLFlicButtonLEDIndicateCount)

    Parameters

    count

    Decides how many times the LED will indicate (fade)

  • A call to this method will read the RSSI (received signal strength indication) of the Flic/PbF while it is currently connected. A callback will be sent to the SCLFlicButton delegate once the value has been updated. This value is represented in decibels and has an effective range from -100 to 0.

    Declaration

    Objective-C

    - (void)readRSSI;

    Swift

    func readRSSI()
  • An integer value representing the last known firmware version of this Flic/PbF.

    Declaration

    Objective-C

    - (int)firmwareRevision;

    Swift

    func firmwareRevision() -> Int32
  • This lets you know what kind of button this is.

    Declaration

    Objective-C

    - (SCLFlicButtonType)buttonType;

    Swift

    func buttonType() -> SCLFlicButtonType

    Return Value

    NSEnum value SCLFlicButtonType