0.1.2 • Published 4 years ago

react-native-inbeacon v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-native-inbeacon

This module is providing a bridge between React Native and the Android / iOS Native SDKs from Inbeacon. This is a third-party module, so it is not developed or maintained by any of the Inbeacon creators themselves. The reason for creating this module was because there was no react-native module for Inbeacon yet, and I had to use it in react-native. So why not publish my code to npm so people can use it and improve it?

Contribution to this module is highly appreciated! 👍

Inbeacon Android SDK: https://github.com/inbeacon/InbeaconSdk-android \ Inbeacon iOS SDK: https://github.com/inbeacon/InbeaconSdk-ios

Installation

$ npm install react-native-inbeacon --save

For react-native versions 0.60 and higher the installation will take place through autolinking.

For react-native versions lower than 0.60, please take a look at the manual installation.

For Android the following permission is required in your AndroidManifest.xml: <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Manual installation

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-inbeacon and add RNInbeacon.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNInbeacon.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

    Android

  5. Open up android/app/src/main/java/[...]/MainActivity.java

    • Add import com.reactlibrary.RNInbeaconPackage; to the imports at the top of the file
    • Add new RNInbeaconPackage() to the list returned by the getPackages() method
  6. Append the following lines to android/settings.gradle:
    include ':react-native-inbeacon'
    project(':react-native-inbeacon').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-inbeacon/android')
  7. Insert the following lines inside the dependencies block in android/app/build.gradle:
      ```
        compile project(':react-native-inbeacon')
      ```

Documentation

Methods

Please take a look at the Android and iOS SDK documentation for a better understanding.

NameParamsReturn valueiOSAndroid
initializeclientId: string,clientSecret: stringPromise<void>
getUserPropertyStringWithFallbackproperty: string,fallback: stringPromise<string>
getUserPropertyStringproperty: stringPromise<string>
putUserPropertyStringproperty: string,value: stringPromise<void>
getUserPropertyLongWithFallbackproperty: string,fallback: numberPromise<number>
getUserPropertyLongproperty: stringPromise<number>
putUserPropertyLongproperty: string,value: numberPromise<void>
getUserPropertyDoubleWithFallbackproperty: string,fallback: numberPromise<number>
getUserPropertyDoubleproperty: stringPromise<number>
putUserPropertyDoubleproperty: string,value: numberPromise<void>
hasTagtag: stringPromise<boolean>
setTagtag: stringPromise<void>
resetTagtag: stringPromise<void>
verifyCapabilitiesNonePromise<string>
setLogLevellevel: LogLevelPromise<void>
getLogLevelNonePromise<string>
setForegroundServicestate: boolean,notification: stringPromise<void>No support
askPermissionNonevoid
setPpidppid: stringPromise<void>
getPpidNonePromise<string>
triggerCustomEventeventId: number,eventType: EventType,extra: stringvoid

Example

import React from 'react';
import RNInbeacon from 'react-native-inbeacon';
import { useEffect } from 'react-native';

export function RNIBTest({ children }) {

  useEffect(() => {
    RNInbeacon.initialize('CLIENT_ID', 'CLIENT_SECRET').then(() => {
      console.log('RNInbeacon is initialized');
    }).catch(err => {
      console.log('RNInbeacon threw an error while initializing', err);
    });
  }, []);

  return (<>{children}</>)
}
0.1.2

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago