1.4.0 • Published 8 years ago

@the-bubbles-company/bubbles-react-native-bridge v1.4.0

Weekly downloads
1
License
-
Repository
-
Last release
8 years ago

react-native-bubbles-react-bridge

Getting started

$ npm i @the-bubbles-company/bubbles-react-native-bridge -S

Mostly automatic installation

$ react-native link @the-bubbles-company/bubbles-react-native-bridge

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules@the-bubbles-company/bubbles-react-native-bridge and add RNBubblesReactBridge.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNBubblesReactBridge.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNBubblesReactBridgePackage; to the imports at the top of the file
  • Add new RNBubblesReactBridgePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-bubbles-react-bridge'
    project(':react-native-bubbles-react-bridge').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-bubbles-react-bridge/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-bubbles-react-bridge')

Usage

import RNBubblesReactBridge from '@the-bubbles-company/bubbles-react-native-bridge';

// TODO: What to do with the module?
RNBubblesReactBridge;

React Bridge API

Structures

Beacon

{
    uuid: "F3077ABE93AC465AACF167F080CB7AEF",
    minor: "CF2F",
    major: "3566",
    event: "IN_NEAR_REGION"
}
Parameters:
NameTypeAttributesDefaultDescription
uuidStringBeacon UUID in Hexadecimal
minorStringBeacon minor in Hexadecimal
majorStringBeacon major in Hexadecimal
eventStringBeacon event: "ENTER", "EXIT", "IN_FAR_REGION", "IN_NEAR_REGION", "IN_IMMEDIATE_REGION"

Service

{
    identifier: "IBC01SRV000000000099",
    name: "Test Service",
    description: "Test Service Description",
    pictoURL: "http://api-sdk.staging.bubbles-company.com/assets/img/service/assets/IBC01SRV000000000099/base/X4/picto_5943a7bbaa425998002626.png?date=20170110",
    pictoSplashURL: "http://api-sdk.staging.bubbles-company.com/assets/img/service/assets/IBC01SRV000000000099/base/X4/picto_splashscreen_5943a7bbc1355691342929.png?date=20170110",
    pictoColor: "#45CEDA"
}
Parameters:
NameTypeAttributesDefaultDescription
identifierStringService identifier
nameStringService name
descriptionStringService description
pictoURLStringService picto URL
pictoSplashURLStringService splash picto URL
pictoColorStringService picto color

Call from React to Phone OS

log(data)

Displays a log in the application's log system for debug purpose.

Parameters:
NameTypeAttributesDefaultDescription
dataStringData to add on application log
Callbacks:

No Callbackss

Event Listener:

No Event Listener

reactIsUpToDate()

On Android only

Needs to be called when the React part is up to date (CodePush integration).

Parameters:

No Parameters

Callbacks:

No Callbackss

Event Listener:

No Event Listener

getVersion()

Gets the application's current Bridge version.

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
versionStringApplication Bridge version

Reject 1:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception

Reject 2:

NameTypeAttributesDefaultDescription
codeIntegerError code 2
messageStringError message Version not found
Event Listener:

No Event Listener

getServices()

Asks for the Services list.

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
servicesArrayServices array
services.rowServiceService object

Reject:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception
Event Listener:

No Event Listener

fetchServices()

Asks the application to update the Services list.

Parameters:

No Parameters

Callbacks:

No Callbackss

Event Listener:

See onServicesChange

openService(service_id)

Asks the application to open a specific Service.

Parameters:
NameTypeAttributesDefaultDescription
serviceIdStringService identifier
Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
successBooleanReturn false when service not found

Reject 1:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception

Reject 2:

NameTypeAttributesDefaultDescription
codeIntegerError code 1
messageStringError message Unknown Service
Event Listener:

No Event Listener

closeService()

Asks the application to close the current Service.

Parameters:

No Parameters

Callbacks:

No Callbackss

Event Listener:

No Event Listener

getBeaconsAround()

Retrieves the Beacons list detected by the phone.

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
beaconsArray<optional>[]Beacons array
beacons.rowBeaconBeacons object

Reject:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception
Event Listener:

No Event Listener

getBluetoothState()

Gets the phone's Bluetooth state.

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
isActivatedBooleanReturn Bluetooth state

Reject:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception
Event Listener:

No Event Listener

getLocalizationPermissionState()

Gets phone's Localization permission state.

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
is_authorizedBooleanReturn Permission state

Reject:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception
Event Listener:

No Event Listener

askForLocalizationPermission()

Asks for phone's Localization permission.

Parameters:

No Parameters

Callbacks:

No callbacks

Event Listener:

See onLocalizationPermissionChange

askForUniqueIdPermission()

On Android only

Asks for phone's Unique Id permission.

Parameters:

No Parameters

Callbacks:

No callbacks

Event Listener:

See onSendUniqueId

enableBluetooth()

Asks application to enable the Bluetooth (without prompting it to the user).

Parameters:

No Parameters

Callbacks:

Resolve:

NameTypeAttributesDefaultDescription
enabledBooleanBluetooth has been enabled successfully

Reject 1:

NameTypeAttributesDefaultDescription
codeIntegerError code 0
messageStringError message JSON Exception

Reject 2:

NameTypeAttributesDefaultDescription
codeIntegerError code 3
messageStringError message Impossible to activate Bluetooth

Reject 3:

NameTypeAttributesDefaultDescription
codeIntegerError code 4
messageStringError message Bluetooth already activated
Event Listener:

No Event Listener

Call from Phone OS to React

onServicesChange(success, services)

Triggers when the Services list is updated.

Parameters:

No Parameters

Callbackw:

No Callbacks

Event Listener:

If succeeded:

NameTypeAttributesDefaultDescription
servicesArrayService list
services.rowServiceService object

If failed:

NameTypeAttributesDefaultDescription
successArrayfalse
messageStringError message

onBeaconChange()

Triggers any Beacon data change.

Parameters:

No Parameters

Callbacks:

No Callbacks

Event Listener:
NameTypeAttributesDefaultDescription
beaconBeaconBeacon new state

onBluetoothStateChange()

Triggers when the Bluetooth state changes.

Parameters:

No Parameters

Callbacks:

No Callbacks

Event Listener:
NameTypeAttributesDefaultDescription
isActivatedBooleanBluetooth state

onLocalizationPermissionChange(success)

Triggers after that the permission question is answered by the user.

Parameters:

No Parameters

Callbacks:

No Callbacks

Event Listener:
NameTypeAttributesDefaultDescription
isAuthorizedBooleanReturn false if user refuse

onSendUniqueId()

On Android only

Triggers after that the permission question is answered by the user.

Parameters:

No Parameters

Callbacks:

No Callbacks

Event Listener:
NameTypeAttributesDefaultDescription
isAuthorizedBooleanReturn false if user refuse
1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago