Skip to content

πŸ”˜ Use the IoT Flic iOS-SDK with Titanium Mobile

License

Notifications You must be signed in to change notification settings

hansemannn/ti.flic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”˜ Ti.Flic

Summary

Ti.Flic is an open-source project to support the Flic iOS-SDK in Appcelerator's Titanium Mobile.

Requirements

  • Titanium Mobile SDK 5.0.0.GA or later
  • iOS 7.0 or later
  • Xcode 7 or later

Setup

  • Optain your API key from the Flic Developer Console
  • Add the following background-modes to the plist-section of your tiapp.xml:
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
</array>
  • Add the url-scheme of your app to the plist-section of your tiapp.xml:
<key>CFBundleURLTypes</key>
<array>
<dict>
    <key>CFBundleURLName</key>
    <string>com.company.yourappid</string>
    <key>CFBundleURLSchemes</key>
    <array>
        <!-- Please ensure that this identifier does not contain any special characters -->
        <string>yourAppURL</string>
    </array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>flic20</string>
</array>

Features

Methods

Name Arguments Return Type
configure args (Object: appID (String), appSecret (String), backgroundExecution (Boolean)
grabFlicFromFlicAppWithCallbackUrlScheme url (String)
enable
disable
onLocationChange
isEnabled Boolean
getButtonByUUID UUID (String) Object
connectButton UUID (String)
disconnectButton UUID (String)
forgetButton UUID (String)
indicateButtonLED UUID (String)
readButtonRSSI UUID (String)
updateButtonTriggerBehavior UUID (String), triggerBehavior (Number)
updateButtonLowLatencyMode UUID (String), enableLowLatency (Boolean)

Properties

Name Type
bluetoothState Number
knownButtons Array

Events

Name
didReceiveButtonDown
didReceiveButtonUp
didReceiveButtonClick
didReceiveButtonDoubleClick
didReceiveButtonHold
flicButtonDidConnect
flicButtonIsReady
didDisconnectWithError
didFailToConnectWithError
didUpdateRSSI
didGrabFlicButton
didChangeBluetoothState
didRestoreState
didForgetButton

Constants

Constant Property
BLUETOOTH_STATE_POWERED_ON bluetoothState
BLUETOOTH_STATE_POWERED_OFF bluetoothState
BLUETOOTH_STATE_RESETTING bluetoothState
BLUETOOTH_STATE_UNSUPPORTED bluetoothState
BLUETOOTH_STATE_UNAUTHORIZED bluetoothState
BLUETOOTH_STATE_UNKNOWN bluetoothState

The following constants are available in the knownButtons property and the events didDisconnectWithError, didFailToConnectWithError and didUpdateRSSI:

Constant Property
CONNECTION_STATE_CONNECTED connectionState
CONNECTION_STATE_CONNECTING connectionState
CONNECTION_STATE_DISCONNECTED connectionState
CONNECTION_STATE_DISCONNECTING connectionState
TRIGGER_BEHAVIOR_CLICK_AND_HOLD triggerBehavior
TRIGGER_BEHAVIOR_CLICK_AND_DOUBLE_CLICK triggerBehavior
TRIGGER_BEHAVIOR_CLICK_AND_DOUBLE_CLICK_AND_HOLD triggerBehavior

Example

Please check the /example/app.js for an example featuring all API's.

Author

Hans Knoechel (@hansemannnn / Web)

License

Apache 2.0

Contributing

Code contributions are greatly appreciated, please submit a new pull request!