Created
March 25, 2017 08:01
-
-
Save sem-nowsquare/bf88b53d6de297be654d1691e034e368 to your computer and use it in GitHub Desktop.
React Native Expo beacon test with react-native-beacons-manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 24 | |
buildToolsVersion '24.0.3' | |
defaultConfig { | |
applicationId "com.xxx.beacontest" | |
minSdkVersion 19 | |
targetSdkVersion 24 | |
versionCode 1 | |
versionName "1.0" | |
multiDexEnabled true | |
ndk { | |
abiFilters 'armeabi-v7a', 'x86' | |
} | |
manifestPlaceholders = [ | |
'appAuthRedirectScheme': 'com.xxx.beacontest' | |
] | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
dexOptions { | |
javaMaxHeapSize "8g" | |
} | |
} | |
task exponentPrebuildStep(type: Exec) { | |
workingDir '../../' | |
if (System.getProperty('os.name').toLowerCase().contains('windows')) { | |
commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat' | |
} else { | |
commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh' | |
} | |
} | |
preBuild.dependsOn exponentPrebuildStep | |
repositories{ | |
flatDir{ | |
dirs 'libs' | |
} | |
mavenLocal() | |
maven { url 'https://maven.fabric.io/public' } | |
} | |
dependencies { | |
compile(project(':react-native-beacons-manager')) { exclude module: 'react-native' } | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
testCompile 'junit:junit:4.12' | |
compile 'com.android.support:appcompat-v7:24.1.1' | |
compile 'com.android.support:multidex:1.0.0' | |
compile('host.exp.exponent:expoview:15.0.0@aar') { | |
exclude group: 'com.facebook.android', module: 'facebook-android-sdk' | |
exclude group: 'com.facebook.android', module: 'audience-network-sdk' | |
exclude group: 'io.nlopez.smartlocation', module: 'library' | |
transitive = true; | |
} | |
compile ('com.facebook.android:facebook-android-sdk:4.7.0') { | |
exclude module: 'bolts-android' | |
} | |
compile('com.facebook.android:audience-network-sdk:4.19.0') { | |
exclude module: 'play-services-ads' | |
} | |
compile('io.nlopez.smartlocation:library:3.2.11') { | |
transitive = false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Expo from 'expo'; | |
import React from 'react'; | |
import { StyleSheet, Text, View, DeviceEventEmitter } from 'react-native'; | |
import Beacons from 'react-native-beacons-manager'; | |
// Tells the library to detect iBeacons | |
Beacons.detectIBeacons(); | |
// Monitoring | |
try { | |
const myRegion = { | |
identifier: 'AXAET-01', | |
uuid: 'fda50693-a4e2-4fb1-afcf-c6eb07647825', | |
minor: 54480, | |
major: 10004 | |
}; | |
Beacons.startMonitoringForRegion(myRegion); | |
console.log('Beacons monitoring started successfully'); | |
} catch (err) { | |
console.log('Beacons monitoring not started, error: ${err}'); | |
} | |
// monitoring: | |
DeviceEventEmitter.addListener( | |
'regionDidEnter', | |
({ identifier, uuid, minor, major }) => { | |
console.log('monitoring - regionDidEnter data: ', { identifier, uuid, minor, major }); | |
} | |
); | |
DeviceEventEmitter.addListener( | |
'regionDidExit', | |
({ identifier, uuid, minor, major }) => { | |
console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); | |
} | |
); | |
class App extends React.Component { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>Open up main.js to start working on your app!</Text> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); | |
Expo.registerRootComponent(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "beacon-test-01", | |
"version": "0.0.0", | |
"description": "Hello Expo!", | |
"author": null, | |
"private": true, | |
"main": "main.js", | |
"dependencies": { | |
"expo": "^15.0.2", | |
"react": "~15.4.0", | |
"react-native": "https://github.com/exponent/react-native/archive/sdk-15.0.0.tar.gz", | |
"react-native-beacons-manager": "^1.0.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment