├── .editorconfig ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .npmignore ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── .vscode └── settings.json ├── BACKGROUND_MODES.md ├── CHANGELOG.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── ReactNativeBeaconsManager.podspec ├── _config.yml ├── android ├── .project ├── .settings │ └── org.eclipse.buildship.core.prefs ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ ├── gradle-wrapper.properties │ │ └── gradle.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── mackentoch │ └── beaconsandroid │ ├── BeaconsAndroidModule.java │ └── BeaconsAndroidPackage.java ├── examples ├── BeaconsDemo │ ├── .babelrc │ ├── .buckconfig │ ├── .editorconfig │ ├── .eslintrc │ ├── .flowconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .nvmrc │ ├── .prettierignore │ ├── .prettierrc │ ├── .vscode │ │ └── launch.json │ ├── .watchmanconfig │ ├── __tests__ │ │ ├── index.android.js │ │ └── index.ios.js │ ├── android │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.buildship.core.prefs │ │ ├── app │ │ │ ├── .classpath │ │ │ ├── .project │ │ │ ├── .settings │ │ │ │ └── org.eclipse.buildship.core.prefs │ │ │ ├── BUCK │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── assets │ │ │ │ └── fonts │ │ │ │ │ ├── Entypo.ttf │ │ │ │ │ ├── EvilIcons.ttf │ │ │ │ │ ├── Feather.ttf │ │ │ │ │ ├── FontAwesome.ttf │ │ │ │ │ ├── Foundation.ttf │ │ │ │ │ ├── Ionicons.ttf │ │ │ │ │ ├── MaterialCommunityIcons.ttf │ │ │ │ │ ├── MaterialIcons.ttf │ │ │ │ │ ├── Octicons.ttf │ │ │ │ │ ├── SimpleLineIcons.ttf │ │ │ │ │ └── Zocial.ttf │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── beaconsdemo │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── keystores │ │ │ ├── BUCK │ │ │ └── debug.keystore.properties │ │ └── settings.gradle │ ├── app.json │ ├── bluetooth-300-300-opacity-45.png │ ├── flow-typed │ │ └── npm │ │ │ ├── babel-cli_vx.x.x.js │ │ │ ├── babel-jest_vx.x.x.js │ │ │ ├── babel-preset-flow_vx.x.x.js │ │ │ ├── babel-preset-react-native_vx.x.x.js │ │ │ ├── flow-bin_v0.x.x.js │ │ │ ├── jest_v18.x.x.js │ │ │ ├── moment_v2.x.x.js │ │ │ ├── react-native-beacons-manager_vx.x.x.js │ │ │ ├── react-native-bluetooth-state_vx.x.x.js │ │ │ └── react-test-renderer_vx.x.x.js │ ├── helpers.js │ ├── images │ │ └── beacons │ │ │ ├── altbeacon.png │ │ │ ├── altbeacon@2x.png │ │ │ ├── altbeacon@3x.png │ │ │ ├── eddystoneURL.png │ │ │ ├── eddystoneURL@2x.png │ │ │ ├── eddystoneURL@3x.png │ │ │ ├── eddystone_TLM.png │ │ │ ├── eddystone_TLM@2x.png │ │ │ ├── eddystone_TLM@3x.png │ │ │ ├── eddystone_UID.png │ │ │ ├── eddystone_UID@2x.png │ │ │ ├── eddystone_UID@3x.png │ │ │ ├── ibeacon@1x.png │ │ │ ├── ibeacon@2x.png │ │ │ └── ibeacon@3x.png │ ├── index.android.js │ ├── index.ios.js │ ├── ios │ │ ├── BeaconsDemo-tvOS │ │ │ └── Info.plist │ │ ├── BeaconsDemo-tvOSTests │ │ │ └── Info.plist │ │ ├── BeaconsDemo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ ├── BeaconsDemo-tvOS.xcscheme │ │ │ │ └── BeaconsDemo.xcscheme │ │ ├── BeaconsDemo │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Base.lproj │ │ │ │ └── LaunchScreen.xib │ │ │ ├── Images.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ ├── Contents.json │ │ │ │ │ ├── RNBeacons-20@2x.png │ │ │ │ │ ├── RNBeacons-20@3x.png │ │ │ │ │ ├── RNBeacons-29@2x.png │ │ │ │ │ ├── RNBeacons-29@3x.png │ │ │ │ │ ├── RNBeacons-40@2x.png │ │ │ │ │ ├── RNBeacons-40@3x.png │ │ │ │ │ ├── RNBeacons-60@2x.png │ │ │ │ │ └── RNBeacons-60@3x.png │ │ │ ├── Info.plist │ │ │ └── main.m │ │ └── BeaconsDemoTests │ │ │ ├── BeaconsDemoTests.m │ │ │ └── Info.plist │ ├── jsconfig.json │ ├── package.json │ ├── typings.json │ ├── typings │ │ ├── globals │ │ │ └── moment │ │ │ │ ├── index.d.ts │ │ │ │ └── typings.json │ │ ├── index.d.ts │ │ └── modules │ │ │ ├── react-native │ │ │ ├── index.d.ts │ │ │ └── typings.json │ │ │ └── react │ │ │ ├── index.d.ts │ │ │ └── typings.json │ └── yarn.lock └── samples │ ├── README.md │ ├── monitoring.android.js │ ├── monitoring.android.md │ ├── monitoring.ios.js │ ├── monitoring.ios.md │ ├── monitoringAndRanging.android.js │ ├── monitoringAndRanging.android.md │ ├── monitoringAndRanging.ios.js │ ├── monitoringAndRanging.ios.md │ ├── multipleBeacon.range.ios.js │ ├── ranging.android.js │ ├── ranging.android.md │ ├── ranging.ios.js │ └── ranging.ios.md ├── images ├── RN-iBeacon.png ├── beacons │ ├── altbeacon.png │ ├── altbeacon@2x.png │ ├── altbeacon@3x.png │ ├── eddystoneURL.png │ ├── eddystoneURL@2x.png │ ├── eddystoneURL@3x.png │ ├── eddystone_TLM.png │ ├── eddystone_TLM@2x.png │ ├── eddystone_TLM@3x.png │ ├── eddystone_UID.png │ ├── eddystone_UID@2x.png │ ├── eddystone_UID@3x.png │ ├── ibeacon@1x.png │ ├── ibeacon@2x.png │ └── ibeacon@3x.png ├── bgmode.gif ├── paypal │ ├── Paypal-button.png │ ├── Paypal-button@2x.png │ └── Paypal-button@3x.png ├── plistRequireAlwaysUseAutorization.png └── plistRequireWhenInUseAutorization.png ├── index.js ├── ios └── RNiBeacon │ ├── RNiBeacon.xcodeproj │ └── project.pbxproj │ └── RNiBeacon │ ├── ESSBeaconScanner.h │ ├── ESSBeaconScanner.m │ ├── ESSEddystone.h │ ├── ESSEddystone.m │ ├── ESSTimer.h │ ├── ESSTimer.m │ ├── RNiBeacon.h │ └── RNiBeacon.m ├── jsconfig.json ├── lib └── next │ ├── module.types.js │ ├── new.module.android.js │ └── new.module.ios.js ├── package.json ├── typings.json ├── typings └── react-native-beacons-manager.d.ts ├── yarn-error.log └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 9 | 10 | 11 | suppress_type=$FlowIssue 12 | suppress_type=$FlowFixMe 13 | suppress_type=$FlowFixMeProps 14 | suppress_type=$FlowFixMeState 15 | suppress_type=$FixMe 16 | 17 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 18 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-7]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 19 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 20 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 21 | suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | .idea 28 | *.iml 29 | .gradle 30 | local.properties 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | Pods/ 37 | AirMapsExplorer.xcworkspace/ 38 | 39 | 40 | # yarn 41 | yarn.lock 42 | yarn-error.log 43 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .eslintrc 2 | .babelrc 3 | 4 | .editorconfig 5 | 6 | examples 7 | 8 | _config.yml 9 | 10 | images 11 | 12 | BACKGROUND_MODES.md 13 | CHANGELOG.md 14 | ISSUE_TEMPLATE.md 15 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.json 2 | **/*.txt 3 | **/*.xml 4 | **/*.svg 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "all", 4 | "bracketSpacing": true, 5 | "jsxBracketSameLine": false, 6 | "singleQuote": true, 7 | "overrides": [], 8 | "printWidth": 80, 9 | "useTabs": false, 10 | "tabWidth": 2, 11 | "parser": "babylon" 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Placez vos paramètres dans ce fichier pour remplacer les paramètres par défaut et les paramètres utilisateur. 2 | { 3 | // coding style and xp: 4 | "editor.tabSize": 2, 5 | "editor.insertSpaces": true, 6 | 7 | "editor.autoClosingBrackets": true, 8 | 9 | // search: 10 | "search.exclude": { 11 | "node_modules": true, 12 | "bower_components": true, 13 | "jspm_packages": true, 14 | ".git": true, 15 | "flow-typed": true, 16 | "__snapshots__": true 17 | }, 18 | 19 | // flow 20 | "javascript.validate.enable": false, 21 | "flow.useNPMPackagedFlow": true, 22 | "flow.pathToFlow": "node_modules/.bin", 23 | "javascript.format.enable": false 24 | } -------------------------------------------------------------------------------- /BACKGROUND_MODES.md: -------------------------------------------------------------------------------- 1 | # Background mode 2 | 3 | ## iOS background mode 4 | 5 | 6 | In the Xcode project: 7 | 8 | **Project settings:** 9 | - go to `Capabilities`, 10 | - switch on `Background Modes` 11 | - and check both 12 | - `Location updates` 13 | - and `Uses Bluetooth LE accessories`. 14 | 15 | ![bgmode](./images/bgmode.gif) 16 | 17 | 18 | **info.plist file:** 19 | 20 | You need `Always authorization` (`WhenInUse` is clearly not enough): 21 | 22 | - add `Privacy - Location Always Usage Description` key defined (*empty value or not. It is better to define a value to a custom / more user-friendly message*). 23 | ![ios: request when in use authorization](./images/plistRequireAlwaysUseAutorization.png) 24 | 25 | 26 | **In your js code** 27 | Use the method `requestAlwaysAuthorization`. 28 | ```javascript 29 | Beacons.requestAlwaysAuthorization(); 30 | ``` 31 | 32 | Finally when killed or sleeping and a beacon is found your whole app wont be loaded. 33 | 34 | So do the tasks (that does not long last since iOS won't let it run more than few seconds): 35 | ```javascript 36 | // monitoring: 37 | DeviceEventEmitter.addListener( 38 | 'regionDidEnter', 39 | (data) => { 40 | // good place for background tasks 41 | console.log('monitoring - regionDidEnter data: ', data); 42 | 43 | const time = moment().format(TIME_FORMAT); 44 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier:data.identifier, uuid:data.uuid, minor:data.minor, major:data.major, time }]) }); 45 | } 46 | ); 47 | 48 | DeviceEventEmitter.addListener( 49 | 'regionDidExit', 50 | ({ identifier, uuid, minor, major }) => { 51 | // good place for background tasks 52 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 53 | 54 | const time = moment().format(TIME_FORMAT); 55 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 56 | } 57 | ); 58 | 59 | ``` 60 | 61 | 62 | ## Android background mode 63 | 64 | **TO ADD** 65 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.0 (COMING SOON) 3 | - iOS: add `allowsBackgroundLocationUpdates(allow: boolean)` to ensure monitoring even if app is killed or in background 4 | - PR #45 thank you to @stoneman1 5 | - PR #54 thank you to @rostislav-simonik 6 | - PR #46 thank you to @ashemah 7 | - PR #58 thank you to @eurobob 8 | - pR #114 thank you to @yohang 9 | - **BEWARE**: *breaking change* = drop of `DeviceEventEmitter` in favor of `Beacons.BeaconsEventEmitter` (see [BeaconsDemo example project](./examples/BeaconsDemo)) 10 | ```javascript 11 | // before 1.1.0 (or until 1.0.7): 12 | DeviceEventEmitter.addListener() 13 | // simply becomes (for both iOS and Android) 14 | Beacons.BeaconsEventEmitter.addListener() 15 | ``` 16 | 17 | - update iOS and Android BeaconsDemo example project 18 | - update samples (*TODO*) 19 | 20 | ## 1.0.8 (CANCELED TO BE v1.1.0, all features included in upper v1.1.0) 21 | - ~~PR #45 thank you to @stoneman1~~ 22 | - ~~PR #54 thank you to @rostislav-simonik~~ 23 | - ~~PR #46 thank you to @ashemah~~ 24 | - ~~PR #58 thank you to @eurobob~~ 25 | - ~~**BEWARE**: *breaking change* = drop of `DeviceEventEmitter` in favor of `Beacons.BeaconsEventEmitter` (see [BeaconsDemo example project](./examples/BeaconsDemo))~~ 26 | ```javascript 27 | // before 1.0.8 (or until 1.0.7): 28 | DeviceEventEmitter.addListener() 29 | // simply becomes (for both iOS and Android) 30 | Beacons.BeaconsEventEmitter.addListener() 31 | ``` 32 | 33 | - ~~update iOS and Android BeaconsDemo example project~~ 34 | - ~~update samples (*TODO*)~~ 35 | 36 | 37 | ## 1.0.7 (RELEASE) 38 | 39 | - improve typescript types 40 | - remove previous non flow typed libs versions (*these before 1.0.7*) 41 | 42 | ## 1.0.7 (RELEASE) 43 | 44 | - iOS: `startRangingBeaconsInRegion` and `startMonitoringForRegion` return promises like android 45 | 46 | - android: `startRangingBeaconsInRegion` and `startMonitoringForRegion` accept an object like iOS and other methods. *NOTE: it won't prevent from accepting current parameters: `regionId: string` and `beaconUUID: string`: not to break existing.* 47 | 48 | - add typescript types 49 | 50 | - fix #40 51 | 52 | ## 1.0.6 (RELEASE) 53 | - fix #38 54 | 55 | ## 1.0.5 (RELEASE) 56 | - improved documentation 57 | - when you want to understand or something's wrong please have a look at [this detailed documentation + code sample](https://github.com/MacKentoch/react-native-beacons-manager/tree/master/examples/samples) 58 | - fix `React Native 0.47` android breaking change: `Remove unused createJSModules` 59 | 60 | ## 1.0.4 (RELEASE) 61 | - same as v1.0.3 (npm publish nightmare...) 62 | 63 | ## 1.0.3 (RELEASED) 64 | - add iOS event `authorizationStatusDidChange` to documentation (=events table in README) 65 | - add new layouts: 66 | - altBeacon 67 | - eddystone (uid, tlm, url) 68 | - PR [#13](https://github.com/MacKentoch/react-native-beacons-manager/pull/13) 69 | - fixes 70 | - iOS monitoring 71 | 72 | ## 1.0.2 (RELEASED) 73 | - fix android monitoring issues when minor and/or minor where null 74 | - add monitoring in example 75 | 76 | ## 1.0.1 (RELEASED) 77 | - README and config fixes 78 | 79 | ## 1.0.0 (RELEASED) 80 | - Initial release 81 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Version 2 | 1.0.1 3 | 4 | ### Platform 5 | iOS | Android 6 | 7 | ### OS version 8 | 9 | iOS 10| android 7.0... 10 | 11 | ### Steps to reproduce 12 | 1. 13 | 2. 14 | 3. 15 | 16 | ### Expected behavior 17 | What should happen 18 | 19 | ### Actual behavior 20 | What is happening 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Erwan DATIN 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ReactNativeBeaconsManager.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ReactNativeBeaconsManager" 3 | s.version = "1.1.0" 4 | s.summary = "React-Native library for detecting beacons (iOS and Android)" 5 | s.homepage = "https://github.com/MacKentoch/react-native-beacons-manager#readme" 6 | s.license = { :type => "MIT" } 7 | s.authors = { "" => "" } 8 | s.platform = :ios, "8.0" 9 | s.source = { :path => "." } 10 | s.source_files = "ios", "ios/**/*.{h,m}" 11 | 12 | s.dependency 'React' 13 | end 14 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | android 4 | Project android created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.3' 9 | } 10 | } 11 | 12 | apply plugin: 'com.android.library' 13 | 14 | 15 | def DEFAULT_COMPILE_SDK_VERSION = 28 16 | def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3" 17 | def DEFAULT_TARGET_SDK_VERSION = 23 18 | 19 | android { 20 | compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION 21 | buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION 22 | 23 | defaultConfig { 24 | minSdkVersion 16 25 | targetSdkVersion project.hasProperty('targetSdkVersion') ? project.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | } 30 | 31 | repositories { 32 | mavenCentral() 33 | jcenter() 34 | google() 35 | 36 | def found = false 37 | def defaultDir = null 38 | def androidSourcesName = 'React Native sources' 39 | 40 | if (rootProject.ext.has('reactNativeAndroidRoot')) { 41 | defaultDir = rootProject.ext.get('reactNativeAndroidRoot') 42 | } else { 43 | defaultDir = new File( 44 | projectDir, 45 | '/../../../node_modules/react-native/android' 46 | ) 47 | } 48 | 49 | if (defaultDir.exists()) { 50 | maven { 51 | url defaultDir.toString() 52 | name androidSourcesName 53 | } 54 | 55 | logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") 56 | found = true 57 | } else { 58 | def parentDir = rootProject.projectDir 59 | 60 | 1.upto(5, { 61 | if (found) return true 62 | parentDir = parentDir.parentFile 63 | 64 | def androidSourcesDir = new File( 65 | parentDir, 66 | 'node_modules/react-native' 67 | ) 68 | 69 | def androidPrebuiltBinaryDir = new File( 70 | parentDir, 71 | 'node_modules/react-native/android' 72 | ) 73 | 74 | if (androidPrebuiltBinaryDir.exists()) { 75 | maven { 76 | url androidPrebuiltBinaryDir.toString() 77 | name androidSourcesName 78 | } 79 | 80 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") 81 | found = true 82 | } else if (androidSourcesDir.exists()) { 83 | maven { 84 | url androidSourcesDir.toString() 85 | name androidSourcesName 86 | } 87 | 88 | logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") 89 | found = true 90 | } 91 | }) 92 | } 93 | 94 | if (!found) { 95 | throw new Exception( 96 | "${project.name}: unable to locate React Native android sources. " + 97 | "Ensure you have you installed React Native as a dependency in your project and try again." 98 | ) 99 | } 100 | } 101 | 102 | 103 | dependencies { 104 | //noinspection GradleDynamicVersion 105 | implementation fileTree(dir: 'libs', include: ['*.jar']) 106 | implementation 'com.facebook.react:react-native:0.6+' 107 | implementation 'com.intellij:annotations:+@jar' 108 | compile 'org.altbeacon:android-beacon-library:2.16.1' 109 | } 110 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 19 22:37:23 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle.properties: -------------------------------------------------------------------------------- 1 | android.useAndroidX=true 2 | android.enableJetifier=true -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /android/src/main/java/com/mackentoch/beaconsandroid/BeaconsAndroidPackage.java: -------------------------------------------------------------------------------- 1 | package com.mackentoch.beaconsandroid; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class BeaconsAndroidPackage implements ReactPackage { 13 | 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | List modules = new ArrayList<>(); 17 | modules.add(new BeaconsAndroidModule(reactContext)); 18 | return modules; 19 | } 20 | 21 | @Override 22 | public List createViewManagers(ReactApplicationContext reactContext) { 23 | return new ArrayList<>(); 24 | } 25 | 26 | public List> createJSModules() { 27 | return new ArrayList<>(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "react-native", 4 | "flow" 5 | ] 6 | } -------------------------------------------------------------------------------- /examples/BeaconsDemo/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | insert_final_newline = true 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | emoji=true 26 | 27 | module.system=haste 28 | 29 | experimental.strict_type_args=true 30 | 31 | munge_underscores=true 32 | 33 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 34 | 35 | suppress_type=$FlowIssue 36 | suppress_type=$FlowFixMe 37 | suppress_type=$FixMe 38 | 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 41 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 42 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 43 | 44 | unsafe.enable_getters_and_setters=true 45 | 46 | [version] 47 | ^0.40.0 48 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.nvmrc: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.json 2 | **/*.txt 3 | **/*.xml 4 | **/*.svg 5 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "all", 4 | "bracketSpacing": true, 5 | "jsxBracketSameLine": false, 6 | "singleQuote": true, 7 | "overrides": [], 8 | "printWidth": 80, 9 | "useTabs": false, 10 | "tabWidth": 2, 11 | "parser": "babylon" 12 | } 13 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | 5 | { 6 | "name": "Debug Android", 7 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 8 | "type": "reactnative", 9 | "request": "launch", 10 | "platform": "android", 11 | "sourceMaps": true, 12 | "outDir": "${workspaceRoot}/.vscode/.react" 13 | }, 14 | { 15 | "name": "Debug iOS", 16 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 17 | "type": "reactnative", 18 | "request": "launch", 19 | "platform": "ios", 20 | "target": "iPhone 5s", 21 | "sourceMaps": true, 22 | "outDir": "${workspaceRoot}/.vscode/.react" 23 | }, 24 | { 25 | "name": "Attach to packager", 26 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 27 | "type": "reactnative", 28 | "request": "attach", 29 | "sourceMaps": true, 30 | "outDir": "${workspaceRoot}/.vscode/.react" 31 | }, 32 | { 33 | "name": "Debug in Exponent", 34 | "program": "${workspaceRoot}/.vscode/launchReactNative.js", 35 | "type": "reactnative", 36 | "request": "launch", 37 | "platform": "exponent", 38 | "sourceMaps": true, 39 | "outDir": "${workspaceRoot}/.vscode/.react" 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /examples/BeaconsDemo/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/BeaconsDemo/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BeaconsDemo 4 | Project BeaconsDemo created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | connection.project.dir= 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | app 4 | Project app created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | #Fri Sep 22 20:11:41 CEST 2017 2 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 3 | eclipse.preferences.version=1 4 | connection.project.dir=.. 5 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] 15 | lib_deps.append(':' + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.beaconsdemo", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.beaconsdemo", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.beaconsdemo" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile project(':react-native-vector-icons') 130 | compile project(':react-native-beacons-manager') 131 | compile fileTree(dir: "libs", include: ["*.jar"]) 132 | compile "com.android.support:appcompat-v7:23.0.1" 133 | compile "com.facebook.react:react-native:+" // From node_modules 134 | } 135 | 136 | // Run this once to be able to run the application with BUCK 137 | // puts all compile dependencies into folder libs for BUCK to use 138 | task copyDownloadableDepsToLibs(type: Copy) { 139 | from configurations.compile 140 | into 'libs' 141 | } 142 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Entypo.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/EvilIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/EvilIcons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Feather.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Feather.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/FontAwesome.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Foundation.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Foundation.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Ionicons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/MaterialIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/MaterialIcons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Octicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Octicons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/SimpleLineIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/SimpleLineIcons.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/assets/fonts/Zocial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/assets/fonts/Zocial.ttf -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/java/com/beaconsdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.beaconsdemo; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "BeaconsDemo"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/java/com/beaconsdemo/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.beaconsdemo; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.oblador.vectoricons.VectorIconsPackage; 7 | import com.mackentoch.beaconsandroid.BeaconsAndroidPackage; 8 | import com.facebook.react.ReactInstanceManager; 9 | import com.facebook.react.ReactNativeHost; 10 | import com.facebook.react.ReactPackage; 11 | import com.facebook.react.shell.MainReactPackage; 12 | import com.facebook.soloader.SoLoader; 13 | 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | public class MainApplication extends Application implements ReactApplication { 18 | 19 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 20 | @Override 21 | public boolean getUseDeveloperSupport() { 22 | return BuildConfig.DEBUG; 23 | } 24 | 25 | @Override 26 | protected List getPackages() { 27 | return Arrays.asList( 28 | new MainReactPackage(), 29 | new VectorIconsPackage(), 30 | new BeaconsAndroidPackage() 31 | ); 32 | } 33 | }; 34 | 35 | @Override 36 | public ReactNativeHost getReactNativeHost() { 37 | return mReactNativeHost; 38 | } 39 | 40 | @Override 41 | public void onCreate() { 42 | super.onCreate(); 43 | SoLoader.init(this, /* native exopackage */ false); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BeaconsDemo 3 | 4 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Feb 25 21:15:41 CET 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'BeaconsDemo' 2 | include ':react-native-vector-icons' 3 | project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') 4 | include ':react-native-beacons-manager' 5 | project(':react-native-beacons-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-beacons-manager/android') 6 | 7 | include ':app' 8 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BeaconsDemo", 3 | "displayName": "BeaconsDemo" 4 | } -------------------------------------------------------------------------------- /examples/BeaconsDemo/bluetooth-300-300-opacity-45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/bluetooth-300-300-opacity-45.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/babel-cli_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 31c6f65ddc39d2c2e2486b7d1a31819a 2 | // flow-typed version: <>/babel-cli_v^6.24.1/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-cli' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-cli' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-cli/bin/babel-doctor' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-cli/bin/babel-external-helpers' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-cli/bin/babel-node' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-cli/bin/babel' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-cli/lib/_babel-node' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-cli/lib/babel-external-helpers' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-cli/lib/babel-node' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'babel-cli/lib/babel/dir' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'babel-cli/lib/babel/file' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'babel-cli/lib/babel/index' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'babel-cli/lib/babel/util' { 66 | declare module.exports: any; 67 | } 68 | 69 | // Filename aliases 70 | declare module 'babel-cli/bin/babel-doctor.js' { 71 | declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>; 72 | } 73 | declare module 'babel-cli/bin/babel-external-helpers.js' { 74 | declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>; 75 | } 76 | declare module 'babel-cli/bin/babel-node.js' { 77 | declare module.exports: $Exports<'babel-cli/bin/babel-node'>; 78 | } 79 | declare module 'babel-cli/bin/babel.js' { 80 | declare module.exports: $Exports<'babel-cli/bin/babel'>; 81 | } 82 | declare module 'babel-cli/index' { 83 | declare module.exports: $Exports<'babel-cli'>; 84 | } 85 | declare module 'babel-cli/index.js' { 86 | declare module.exports: $Exports<'babel-cli'>; 87 | } 88 | declare module 'babel-cli/lib/_babel-node.js' { 89 | declare module.exports: $Exports<'babel-cli/lib/_babel-node'>; 90 | } 91 | declare module 'babel-cli/lib/babel-external-helpers.js' { 92 | declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>; 93 | } 94 | declare module 'babel-cli/lib/babel-node.js' { 95 | declare module.exports: $Exports<'babel-cli/lib/babel-node'>; 96 | } 97 | declare module 'babel-cli/lib/babel/dir.js' { 98 | declare module.exports: $Exports<'babel-cli/lib/babel/dir'>; 99 | } 100 | declare module 'babel-cli/lib/babel/file.js' { 101 | declare module.exports: $Exports<'babel-cli/lib/babel/file'>; 102 | } 103 | declare module 'babel-cli/lib/babel/index.js' { 104 | declare module.exports: $Exports<'babel-cli/lib/babel/index'>; 105 | } 106 | declare module 'babel-cli/lib/babel/util.js' { 107 | declare module.exports: $Exports<'babel-cli/lib/babel/util'>; 108 | } 109 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/babel-jest_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 958765b2e432d2f5243fecc7a6c3f71d 2 | // flow-typed version: <>/babel-jest_v18.0.0/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-jest' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-jest' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-jest/build/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-jest/build/index.js' { 31 | declare module.exports: $Exports<'babel-jest/build/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/babel-preset-flow_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 5f1298f20d2329f008c4e3913692b542 2 | // flow-typed version: <>/babel-preset-flow_v^6.23.0/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-flow' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-flow' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-flow/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-flow/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-flow/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/babel-preset-react-native_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 9ece78f4082d486f7ad026bacc70e0b5 2 | // flow-typed version: <>/babel-preset-react-native_v1.9.1/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-react-native' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-react-native' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-react-native/configs/hmr' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-preset-react-native/configs/internal' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-preset-react-native/configs/main' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-preset-react-native/lib/resolvePlugins' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-preset-react-native/plugins' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-preset-react-native/transforms/transform-symbol-member' { 46 | declare module.exports: any; 47 | } 48 | 49 | // Filename aliases 50 | declare module 'babel-preset-react-native/configs/hmr.js' { 51 | declare module.exports: $Exports<'babel-preset-react-native/configs/hmr'>; 52 | } 53 | declare module 'babel-preset-react-native/configs/internal.js' { 54 | declare module.exports: $Exports<'babel-preset-react-native/configs/internal'>; 55 | } 56 | declare module 'babel-preset-react-native/configs/main.js' { 57 | declare module.exports: $Exports<'babel-preset-react-native/configs/main'>; 58 | } 59 | declare module 'babel-preset-react-native/index' { 60 | declare module.exports: $Exports<'babel-preset-react-native'>; 61 | } 62 | declare module 'babel-preset-react-native/index.js' { 63 | declare module.exports: $Exports<'babel-preset-react-native'>; 64 | } 65 | declare module 'babel-preset-react-native/lib/resolvePlugins.js' { 66 | declare module.exports: $Exports<'babel-preset-react-native/lib/resolvePlugins'>; 67 | } 68 | declare module 'babel-preset-react-native/plugins.js' { 69 | declare module.exports: $Exports<'babel-preset-react-native/plugins'>; 70 | } 71 | declare module 'babel-preset-react-native/transforms/transform-symbol-member.js' { 72 | declare module.exports: $Exports<'babel-preset-react-native/transforms/transform-symbol-member'>; 73 | } 74 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/flow-bin_v0.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583 2 | // flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x 3 | 4 | declare module "flow-bin" { 5 | declare module.exports: string; 6 | } 7 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/react-native-beacons-manager_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: dc92b4b3a2f160552d732ee766866b95 2 | // flow-typed version: <>/react-native-beacons-manager_vhttps://github.com/MacKentoch/react-native-beacons-manager.git/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'react-native-beacons-manager' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'react-native-beacons-manager' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.android' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.ios' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/index.android' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/index.ios' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'react-native-beacons-manager/examples/samples/monitoring.android' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'react-native-beacons-manager/examples/samples/monitoring.ios' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'react-native-beacons-manager/examples/samples/monitoringAndRanging.android' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'react-native-beacons-manager/examples/samples/monitoringAndRanging.ios' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'react-native-beacons-manager/examples/samples/multipleBeacon.range.ios' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'react-native-beacons-manager/examples/samples/ranging.android' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'react-native-beacons-manager/examples/samples/ranging.ios' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'react-native-beacons-manager/lib/module.android' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'react-native-beacons-manager/lib/module.ios' { 74 | declare module.exports: any; 75 | } 76 | 77 | // Filename aliases 78 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.android.js' { 79 | declare module.exports: $Exports<'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.android'>; 80 | } 81 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.ios.js' { 82 | declare module.exports: $Exports<'react-native-beacons-manager/examples/BeaconsDemo/__tests__/index.ios'>; 83 | } 84 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/index.android.js' { 85 | declare module.exports: $Exports<'react-native-beacons-manager/examples/BeaconsDemo/index.android'>; 86 | } 87 | declare module 'react-native-beacons-manager/examples/BeaconsDemo/index.ios.js' { 88 | declare module.exports: $Exports<'react-native-beacons-manager/examples/BeaconsDemo/index.ios'>; 89 | } 90 | declare module 'react-native-beacons-manager/examples/samples/monitoring.android.js' { 91 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/monitoring.android'>; 92 | } 93 | declare module 'react-native-beacons-manager/examples/samples/monitoring.ios.js' { 94 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/monitoring.ios'>; 95 | } 96 | declare module 'react-native-beacons-manager/examples/samples/monitoringAndRanging.android.js' { 97 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/monitoringAndRanging.android'>; 98 | } 99 | declare module 'react-native-beacons-manager/examples/samples/monitoringAndRanging.ios.js' { 100 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/monitoringAndRanging.ios'>; 101 | } 102 | declare module 'react-native-beacons-manager/examples/samples/multipleBeacon.range.ios.js' { 103 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/multipleBeacon.range.ios'>; 104 | } 105 | declare module 'react-native-beacons-manager/examples/samples/ranging.android.js' { 106 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/ranging.android'>; 107 | } 108 | declare module 'react-native-beacons-manager/examples/samples/ranging.ios.js' { 109 | declare module.exports: $Exports<'react-native-beacons-manager/examples/samples/ranging.ios'>; 110 | } 111 | declare module 'react-native-beacons-manager/index' { 112 | declare module.exports: $Exports<'react-native-beacons-manager'>; 113 | } 114 | declare module 'react-native-beacons-manager/index.js' { 115 | declare module.exports: $Exports<'react-native-beacons-manager'>; 116 | } 117 | declare module 'react-native-beacons-manager/lib/module.android.js' { 118 | declare module.exports: $Exports<'react-native-beacons-manager/lib/module.android'>; 119 | } 120 | declare module 'react-native-beacons-manager/lib/module.ios.js' { 121 | declare module.exports: $Exports<'react-native-beacons-manager/lib/module.ios'>; 122 | } 123 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/flow-typed/npm/react-native-bluetooth-state_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 238220250dffead82724f1097a354d11 2 | // flow-typed version: <>/react-native-bluetooth-state_v^2.0.0/flow_v0.40.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'react-native-bluetooth-state' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'react-native-bluetooth-state' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'react-native-bluetooth-state/Example/index.android' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'react-native-bluetooth-state/Example/index.ios' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'react-native-bluetooth-state/RNBluetoothState.android' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'react-native-bluetooth-state/RNBluetoothState.ios' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'react-native-bluetooth-state/Example/index.android.js' { 43 | declare module.exports: $Exports<'react-native-bluetooth-state/Example/index.android'>; 44 | } 45 | declare module 'react-native-bluetooth-state/Example/index.ios.js' { 46 | declare module.exports: $Exports<'react-native-bluetooth-state/Example/index.ios'>; 47 | } 48 | declare module 'react-native-bluetooth-state/RNBluetoothState.android.js' { 49 | declare module.exports: $Exports<'react-native-bluetooth-state/RNBluetoothState.android'>; 50 | } 51 | declare module 'react-native-bluetooth-state/RNBluetoothState.ios.js' { 52 | declare module.exports: $Exports<'react-native-bluetooth-state/RNBluetoothState.ios'>; 53 | } 54 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/helpers.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | /* eslint-disable no-bitwise */ 4 | 5 | // #region flow types 6 | export type Beacon = { 7 | identifier: string, 8 | uuid?: string, 9 | major?: number, 10 | minor?: number, 11 | proximity?: string, 12 | rssi?: string, 13 | distance?: number, 14 | }; 15 | // #endregion 16 | 17 | export const hashCode = (str: string): string => { 18 | return str 19 | .split('') 20 | .reduce( 21 | (prevHash, currVal) => 22 | ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 23 | 0, 24 | ); 25 | }; 26 | 27 | export const deepCopyBeaconsLists = ( 28 | beaconsLists: Array, 29 | ): Array => { 30 | const initial = {}; 31 | return Object.keys(beaconsLists) 32 | .map(key => ({ [key]: [...beaconsLists[key]] })) 33 | .reduce((prev, next) => { 34 | return { ...prev, ...next }; 35 | }, initial); 36 | }; 37 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/altbeacon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/altbeacon.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/altbeacon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/altbeacon@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/altbeacon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/altbeacon@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystoneURL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystoneURL.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystoneURL@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystoneURL@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystoneURL@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystoneURL@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_TLM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_TLM.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_TLM@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_TLM@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_TLM@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_TLM@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_UID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_UID.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_UID@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_UID@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/eddystone_UID@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/eddystone_UID@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/ibeacon@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/ibeacon@1x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/ibeacon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/ibeacon@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/images/beacons/ibeacon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/images/beacons/ibeacon@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo.xcodeproj/xcshareddata/xcschemes/BeaconsDemo-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo.xcodeproj/xcshareddata/xcschemes/BeaconsDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"BeaconsDemo" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "RNBeacons-20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "RNBeacons-20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "RNBeacons-29@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "RNBeacons-29@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "RNBeacons-40@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "RNBeacons-40@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "RNBeacons-60@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "RNBeacons-60@3x.png", 49 | "scale" : "3x" 50 | } 51 | ], 52 | "info" : { 53 | "version" : 1, 54 | "author" : "xcode" 55 | } 56 | } -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-20@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-20@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-29@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-29@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-40@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-40@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-60@2x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/examples/BeaconsDemo/ios/BeaconsDemo/Images.xcassets/AppIcon.appiconset/RNBeacons-60@3x.png -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSLocationWhenInUseUsageDescription 6 | WRITE YOUR MESSAGE (OR LEAVE BLANK) TO EXPLAIN USER WHY YOU NEED LOCATION SERVICE 7 | NSLocationAlwaysUsageDescription 8 | WRITE YOUR MESSAGE (OR LEAVE BLANK) TO EXPLAIN USER WHY YOU NEED LOCATION SERVICE 9 | NSLocationAlwaysAndWhenInUseUsageDescription 10 | WRITE YOUR MESSAGE (OR LEAVE BLANK) TO EXPLAIN USER WHY YOU NEED LOCATION SERVICE 11 | CFBundleDevelopmentRegion 12 | en 13 | CFBundleDisplayName 14 | BeaconsDemo 15 | CFBundleExecutable 16 | $(EXECUTABLE_NAME) 17 | CFBundleIdentifier 18 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 19 | CFBundleInfoDictionaryVersion 20 | 6.0 21 | CFBundleName 22 | $(PRODUCT_NAME) 23 | CFBundlePackageType 24 | APPL 25 | CFBundleShortVersionString 26 | 1.0 27 | CFBundleSignature 28 | ???? 29 | CFBundleVersion 30 | 1 31 | LSRequiresIPhoneOS 32 | 33 | NSAppTransportSecurity 34 | 35 | NSExceptionDomains 36 | 37 | localhost 38 | 39 | NSExceptionAllowsInsecureHTTPLoads 40 | 41 | 42 | 43 | 44 | UIBackgroundModes 45 | 46 | bluetooth-central 47 | location 48 | 49 | UILaunchStoryboardName 50 | LaunchScreen 51 | UIRequiredDeviceCapabilities 52 | 53 | armv7 54 | 55 | UISupportedInterfaceOrientations 56 | 57 | UIInterfaceOrientationPortrait 58 | UIInterfaceOrientationLandscapeLeft 59 | UIInterfaceOrientationLandscapeRight 60 | 61 | UIViewControllerBasedStatusBarAppearance 62 | 63 | UIAppFonts 64 | 65 | Entypo.ttf 66 | EvilIcons.ttf 67 | Feather.ttf 68 | FontAwesome.ttf 69 | Foundation.ttf 70 | Ionicons.ttf 71 | MaterialCommunityIcons.ttf 72 | MaterialIcons.ttf 73 | Octicons.ttf 74 | SimpleLineIcons.ttf 75 | Zocial.ttf 76 | 77 | 78 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemo/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemoTests/BeaconsDemoTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface BeaconsDemoTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation BeaconsDemoTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/ios/BeaconsDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": [ 3 | "node_modules", 4 | "android", 5 | "ios", 6 | "images", 7 | "example" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BeaconsDemo", 3 | "version": "0.2.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest", 8 | "shake-android-simulator": "adb shell input keyevent 82", 9 | "postinstall": "rndebugger-open" 10 | }, 11 | "dependencies": { 12 | "flow-bin": "^0.69.0", 13 | "moment": "^2.29.2", 14 | "react": "16.0.0-alpha.6", 15 | "react-native": "0.43.3", 16 | "react-native-beacons-manager": "git+https://github.com/MacKentoch/react-native-beacons-manager.git", 17 | "react-native-bluetooth-state": "^2.0.0", 18 | "react-native-elements": "^0.18.0", 19 | "react-native-vector-icons": "^4.4.2" 20 | }, 21 | "devDependencies": { 22 | "babel-cli": "^6.24.1", 23 | "babel-jest": "18.0.0", 24 | "babel-preset-flow": "^6.23.0", 25 | "babel-preset-react-native": "1.9.1", 26 | "jest": "18.1.0", 27 | "react-native-debugger-open": "^0.3.15", 28 | "react-test-renderer": "~15.4.0" 29 | }, 30 | "jest": { 31 | "preset": "react-native" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BeaconsDemo", 3 | "dependencies": {} 4 | } 5 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/typings/globals/moment/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/637e7d6df755e785387d5269cb9287cdc51b8cb7/moment/moment.d.ts", 5 | "raw": "registry:dt/moment#2.11.1+20161010105546", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/637e7d6df755e785387d5269cb9287cdc51b8cb7/moment/moment.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/typings/modules/react-native/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6241f19520e3ab6e62dd3b6f8cc8e75b89469a80/react-native/index.d.ts", 5 | "raw": "registry:dt/react-native#0.42.0+20170324170601", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6241f19520e3ab6e62dd3b6f8cc8e75b89469a80/react-native/index.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/BeaconsDemo/typings/modules/react/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolution": "main", 3 | "tree": { 4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6ffca66c9d1edfdfa1f42f8d82db59e4297e302b/react/index.d.ts", 5 | "raw": "registry:dt/react#15.0.0+20170324160437", 6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6ffca66c9d1edfdfa1f42f8d82db59e4297e302b/react/index.d.ts" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/samples/README.md: -------------------------------------------------------------------------------- 1 | # Detailed documentation + sample code 2 | 3 | For my concern when I started playing with beacon I didn't even have a clue what was a beacon. 4 | 5 | This documentation is the one I would have been pleased to have at that time. 6 | 7 | This documentation is written to make your life easier and to give and you answers before you ask yourself the questions. 8 | 9 | ## iOS 10 | 11 | iOS will ask you a bit more attention and configuration. 12 | 13 | - [ranging (only)](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.md) 14 | - [monitoring (only)](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.md) 15 | - [monitoring and ranging at same time](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.ios.md) 16 | - [multiple beacons ranging full example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/multipleBeacon.range.ios.js) 17 | 18 | 19 | *Don't forget to activate bluetooth on your device.* 20 | 21 | ## Android 22 | 23 | Android asks less configuration. 24 | 25 | - [ranging (only)](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.android.md) 26 | - [monitoring (only)](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.android.md) 27 | - [monitoring and ranging at same time](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.android.md) 28 | 29 | *Android `bluetooth service is required` but depending your version it not always enough:* 30 | - android >= 7 31 | - activate `bluetooth service` on your phone *= OK it works* 32 | - android < 7 33 | - activate `bluetooth service` on your phone *= not enough alone...* 34 | - activate `location service` 35 | -------------------------------------------------------------------------------- /examples/samples/monitoring.android.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import Beacons from 'react-native-beacons-manager'; 4 | import moment from 'moment'; 5 | 6 | const TIME_FORMAT = 'MM/DD/YYYY HH:mm:ss'; 7 | 8 | class beaconMonitoringOnly extends Component { 9 | // will be set as a reference to "beaconsDidRange" event: 10 | beaconsDidRangeEvent = null; 11 | // will be set as a reference to "regionDidEnter" event: 12 | regionDidEnterEvent = null; 13 | 14 | state = { 15 | // region information 16 | uuid: '7b44b47b-52a1-5381-90c2-f09b6838c5d4', 17 | identifier: 'some id', 18 | 19 | regionEnterDatasource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]), 20 | regionExitDatasource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]) 21 | }; 22 | 23 | componentWillMount() { 24 | const { identifier, uuid } = this.state; 25 | // 26 | // ONLY non component state aware here in componentWillMount 27 | // 28 | 29 | // Define a region which can be identifier + uuid, 30 | // identifier + uuid + major or identifier + uuid + major + minor 31 | // (minor and major properties are 'OPTIONAL' numbers) 32 | const region = { identifier, uuid }; 33 | 34 | // start iBeacon detection (later will add Eddystone and Nordic Semiconductor beacons) 35 | Beacons.detectIBeacons(); 36 | // Monitor beacons inside the region 37 | Beacons 38 | .startMonitoringForRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 39 | .then(() => console.log('Beacons monitoring started succesfully')) 40 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 41 | } 42 | 43 | componentDidMount() { 44 | // 45 | // component state aware here - attach events 46 | // 47 | 48 | // monitoring: 49 | this.beaconsDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 50 | 'regionDidEnter', 51 | ({ identifier, uuid, minor, major }) => { 52 | console.log('monitoring - regionDidEnter data: ', { identifier, uuid, minor, major }); 53 | const time = moment().format(TIME_FORMAT); 54 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 55 | } 56 | ); 57 | 58 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 59 | 'regionDidExit', 60 | ({ identifier, uuid, minor, major }) => { 61 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 62 | const time = moment().format(TIME_FORMAT); 63 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 64 | } 65 | ); 66 | } 67 | 68 | componentWillUnMount() { 69 | const { uuid, identifier } = this.state; 70 | const region = { identifier, uuid }; 71 | 72 | // stop monitoring beacons: 73 | Beacons 74 | .stopMonitoringForRegion(region) // or like < v1.0.7: .stopMonitoringForRegion(identifier, uuid) 75 | .then(() => console.log('Beacons monitoring stopped succesfully')) 76 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 77 | 78 | // remove beacons events we registered at componentDidMount 79 | this.regionDidEnterEvent.remove(); 80 | this.regionDidExitEvent.remove(); 81 | } 82 | 83 | render() { 84 | const { bluetoothState, regionEnterDatasource, regionExitDatasource } = this.state; 85 | 86 | return ( 87 | 88 | 89 | monitoring enter information: 90 | 91 | 96 | 97 | 98 | monitoring exit information: 99 | 100 | 105 | 106 | ); 107 | } 108 | 109 | renderMonitoringEnterRow = ({ identifier, uuid, minor, major, time }) => { 110 | return ( 111 | 112 | 113 | Identifier: {identifier ? identifier : 'NA'} 114 | 115 | 116 | UUID: {uuid ? uuid : 'NA'} 117 | 118 | 119 | Major: {major ? major : ''} 120 | 121 | 122 | Minor: { minor ? minor : ''} 123 | 124 | 125 | time: { time ? time : 'NA'} 126 | 127 | 128 | ); 129 | } 130 | 131 | renderMonitoringLeaveRow = ({ identifier, uuid, minor, major, time }) => { 132 | return ( 133 | 134 | 135 | Identifier: {identifier ? identifier : 'NA'} 136 | 137 | 138 | UUID: {uuid ? uuid : 'NA'} 139 | 140 | 141 | Major: {major ? major : ''} 142 | 143 | 144 | Minor: { minor ? minor : ''} 145 | 146 | 147 | time: { time ? time : 'NA'} 148 | 149 | 150 | ); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /examples/samples/monitoring.android.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "monitoring beacons in Android" 2 | 3 | This documentation give a deeper explanation on how to monitor (*but monitoring only*) beacons in Android. 4 | 5 | This documentation is linked to the sample code [monitoring.android.js](./monitoring.android.js) 6 | 7 | ## 1- start detection for beacon of your choice 8 | 9 | Before starting tell the library what kind of beacon you want to manage. 10 | 11 | ```javascript 12 | // dealing with iBeacons: 13 | Beacons.detectIBeacons(); 14 | ``` 15 | 16 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.android.js#L33) 17 | 18 | ## 2- start monitoring 19 | 20 | Tell Android what you want to monitor by defining a desired `region` object. 21 | 22 | 23 | ```javascript 24 | // Define a region which can be identifier + uuid, 25 | // identifier + uuid + major or identifier + uuid + major + minor 26 | // (minor and major properties are 'OPTIONAL' numbers) 27 | const region = { identifier, uuid }; 28 | 29 | // Monitor beacons inside the region 30 | Beacons 31 | .startMonitoringForRegion(region) 32 | .then(() => console.log('Beacons monitoring started succesfully')) 33 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 34 | ``` 35 | 36 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.android.js#L35) 37 | 38 | ## 3- register events 39 | 40 | Monitoring now works. 41 | 42 | You have to register events to know and use about data from enter region and leave region events. 43 | 44 | ```javascript 45 | 46 | // Monitoring: Listen for device entering the defined region 47 | this.beaconsDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 48 | 'regionDidEnter', 49 | ({ identifier, uuid, minor, major }) => { 50 | console.log('monitoring - regionDidEnter data: ', { identifier, uuid, minor, major }); 51 | const time = moment().format(TIME_FORMAT); 52 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 53 | } 54 | ); 55 | 56 | // Monitoring: Listen for device leaving the defined region 57 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 58 | 'regionDidExit', 59 | ({ identifier, uuid, minor, major }) => { 60 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 61 | const time = moment().format(TIME_FORMAT); 62 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 63 | } 64 | ); 65 | ``` 66 | 67 | **IMPORTANT:** 68 | - **`regionDidExit` will trigger `ONLY after` a timeout of `30 seconds` when having left region (= beacons no more detected)** 69 | 70 | - **if you start the monotoring when already in region, `regionDidEnter` will not trigger first time. (leave region and wait at least 30 seconds then enter again the region)** 71 | 72 | 73 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.android.js#L47) 74 | 75 | 76 | ## 4- on componentWillUnMount: unregister events and stop monitoring 77 | 78 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 79 | 80 | Tell Android to stop monitoring at the same time. 81 | 82 | ```javascript 83 | const { uuid, identifier } = this.state; 84 | const region = { identifier, uuid }; 85 | 86 | // stop monitoring beacons: 87 | Beacons 88 | .stopMonitoringForRegion(region) 89 | .then(() => console.log('Beacons monitoring stopped succesfully')) 90 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 91 | 92 | // remove beacons events we registered at componentDidMount 93 | this.regionDidEnterEvent.remove(); 94 | this.regionDidExitEvent.remove(); 95 | ``` 96 | 97 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.android.js#L71) 98 | -------------------------------------------------------------------------------- /examples/samples/monitoring.ios.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import Beacons from 'react-native-beacons-manager'; 4 | import moment from 'moment'; 5 | 6 | const TIME_FORMAT = 'MM/DD/YYYY HH:mm:ss'; 7 | 8 | class beaconMonitoringOnly extends Component { 9 | // will be set as a reference to "regionDidEnter" event: 10 | regionDidEnterEvent = null; 11 | // will be set as a reference to "regionDidExit" event: 12 | regionDidExitEvent = null; 13 | // will be set as a reference to "authorizationStatusDidChange" event: 14 | authStateDidRangeEvent = null; 15 | 16 | state = { 17 | // region information 18 | uuid: '7b44b47b-52a1-5381-90c2-f09b6838c5d4', 19 | identifier: 'some id', 20 | 21 | regionEnterDatasource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]), 22 | regionExitDatasource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]) 23 | }; 24 | 25 | componentWillMount() { 26 | const { identifier, uuid } = this.state; 27 | // 28 | // ONLY non component state aware here in componentWillMount 29 | // 30 | 31 | // OPTIONAL: listen to authorization change 32 | this.authStateDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 33 | 'authorizationStatusDidChange', 34 | (info) => console.log('authorizationStatusDidChange: ', info) 35 | ); 36 | 37 | // MANDATORY: you have to request ALWAYS Authorization (not only when in use) when monitoring 38 | // you also have to add "Privacy - Location Always Usage Description" in your "Info.plist" file 39 | // otherwise monitoring won't work 40 | Beacons.requestAlwaysAuthorization(); 41 | Beacons.shouldDropEmptyRanges(true); 42 | 43 | // Define a region which can be identifier + uuid, 44 | // identifier + uuid + major or identifier + uuid + major + minor 45 | // (minor and major properties are numbers) 46 | const region = { identifier, uuid }; 47 | // Monitor for beacons inside the region 48 | Beacons 49 | .startMonitoringForRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 50 | .then(() => console.log('Beacons monitoring started succesfully')) 51 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 52 | // update location to ba able to monitor: 53 | Beacons.startUpdatingLocation(); 54 | } 55 | 56 | componentDidMount() { 57 | // 58 | // component state aware here - attach events 59 | // 60 | 61 | // monitoring: 62 | this.regionDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 63 | 'regionDidEnter', 64 | (data) => { 65 | console.log('monitoring - regionDidEnter data: ', data); 66 | const time = moment().format(TIME_FORMAT); 67 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier:data.identifier, uuid:data.uuid, minor:data.minor, major:data.major, time }]) }); 68 | } 69 | ); 70 | 71 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 72 | 'regionDidExit', 73 | ({ identifier, uuid, minor, major }) => { 74 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 75 | const time = moment().format(TIME_FORMAT); 76 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 77 | } 78 | ); 79 | } 80 | 81 | componentWillUnMount() { 82 | // stop monitoring beacons: 83 | Beacons 84 | .stopMonitoringForRegion(region) 85 | .then(() => console.log('Beacons monitoring stopped succesfully')) 86 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 87 | // stop updating locationManager: 88 | Beacons.stopUpdatingLocation(); 89 | // remove auth state event we registered at componentDidMount: 90 | this.authStateDidRangeEvent.remove(); 91 | // remove monitiring events we registered at componentDidMount:: 92 | this.regionDidEnterEvent.remove(); 93 | this.regionDidExitEvent.remove(); 94 | } 95 | 96 | render() { 97 | const { bluetoothState, regionEnterDatasource, regionExitDatasource } = this.state; 98 | 99 | return ( 100 | 101 | 102 | monitoring enter information: 103 | 104 | 109 | 110 | 111 | monitoring exit information: 112 | 113 | 118 | 119 | ); 120 | } 121 | 122 | renderMonitoringEnterRow = ({ identifier, uuid, minor, major, time }) => { 123 | return ( 124 | 125 | 126 | Identifier: {identifier ? identifier : 'NA'} 127 | 128 | 129 | UUID: {uuid ? uuid : 'NA'} 130 | 131 | 132 | Major: {major ? major : ''} 133 | 134 | 135 | Minor: { minor ? minor : ''} 136 | 137 | 138 | time: { time ? time : 'NA'} 139 | 140 | 141 | ); 142 | } 143 | 144 | renderMonitoringLeaveRow = ({ identifier, uuid, minor, major, time }) => { 145 | return ( 146 | 147 | 148 | Identifier: {identifier ? identifier : 'NA'} 149 | 150 | 151 | UUID: {uuid ? uuid : 'NA'} 152 | 153 | 154 | Major: {major ? major : ''} 155 | 156 | 157 | Minor: { minor ? minor : ''} 158 | 159 | 160 | time: { time ? time : 'NA'} 161 | 162 | 163 | ); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /examples/samples/monitoring.ios.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "monitoring beacons in iOS" 2 | 3 | This documentation give a deeper explanation on how to monitor (*but monitoring only*) beacons in iOS. 4 | 5 | This documentation is linked to the sample code [monitoring.ios.js](./monitoring.ios.js) 6 | 7 | ## 1- request authorization 8 | 9 | When dealing with Beacons, you technically deal with native location ([see Apple documentation](https://developer.apple.com/reference/corelocation/cllocationmanager)). 10 | 11 | Before starting ranging, iOS force you to ask for authorization in case of location services. 12 | 13 | If you don't: 14 | - it won't generate an error 15 | - but nothing will happen until you have authorization 16 | 17 | 18 | > For monitoring you don't have the choice you have to request `Always` authorization wether you need background mode or not. 19 | 20 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L36) 21 | 22 | ### 1 `Beacons.requestAlwaysAuthorization();` (**background and foreground use-case**) 23 | 24 | #### in your react native application 25 | Ensure to call 26 | 27 | ```javascript 28 | Beacons.requestAlwaysAuthorization(); 29 | ``` 30 | 31 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L36) 32 | 33 | #### in your iOS project 34 | 35 | To be effective your `info.plist` file should have `Privacy - Location Always Usage Description` key defined (*empty value or not. It is better to define a value to a custom / more user-friendly message*). 36 | 37 | *You have to manually `add it` to your `info.plist`:* 38 | 39 | ![ios: request when in use authorization](../../images/plistRequireAlwaysUseAutorization.png) 40 | 41 | ## 2- start monitoring 42 | 43 | Tell iOS what you want to range by defining a desired `region` object. 44 | 45 | 46 | ```javascript 47 | // Define a region which can be identifier + uuid, 48 | // identifier + uuid + major or identifier + uuid + major + minor 49 | // (minor and major properties are numbers) 50 | const region = { identifier, uuid }; 51 | 52 | // Monitor beacons inside the region 53 | Beacons.startMonitoringForRegion(region) 54 | .then(() => console.log('Beacons monitoring started succesfully')) 55 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 56 | ``` 57 | 58 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L43) 59 | 60 | ## 3- get the position of the device 61 | 62 | Monitoring needs you to get position of the device. 63 | 64 | Just call: 65 | ```javascript 66 | Beacons.startUpdatingLocation(); 67 | ``` 68 | 69 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L45) 70 | 71 | ## 4- register events 72 | 73 | Monitoring now works. 74 | 75 | You have to register events to know and use about data from enter region and leave region events. 76 | 77 | ```javascript 78 | 79 | // Monitoring: Listen for device entering the defined region 80 | this.regionDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 81 | 'regionDidEnter', 82 | (data) => { 83 | console.log('monitoring - regionDidEnter data: ', data); 84 | const time = moment().format(TIME_FORMAT); 85 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier:data.identifier, uuid:data.uuid, minor:data.minor, major:data.major, time }]) }); 86 | } 87 | ); 88 | 89 | // Monitoring: Listen for device leaving the defined region 90 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 91 | 'regionDidExit', 92 | ({ identifier, uuid, minor, major }) => { 93 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 94 | const time = moment().format(TIME_FORMAT); 95 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 96 | } 97 | ); 98 | ``` 99 | 100 | **IMPORTANT:** 101 | - **`regionDidExit` will trigger `ONLY after` a timeout of `30 seconds` when having left region (= beacons no more detected)** 102 | 103 | - **if you start the monotoring when already in region, `regionDidEnter` will not trigger first time. (leave region and wait at least 30 seconds then enter again the region)** 104 | 105 | 106 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L54) 107 | 108 | 109 | ## 5- on componentWillUnMount: unregister events and stop monitoring 110 | 111 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 112 | 113 | Tell iOS to stop ranging at the same time. 114 | 115 | ```javascript 116 | // stop monitoring beacons: 117 | Beacons 118 | .stopMonitoringForRegion(region) 119 | .then(() => console.log('Beacons monitoring stopped succesfully')) 120 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 121 | // stop updating locationManager: 122 | Beacons.stopUpdatingLocation(); 123 | // remove auth state event we registered at componentDidMount: 124 | this.authStateDidRangeEvent.remove(); 125 | // remove monitiring events we registered at componentDidMount:: 126 | this.regionDidEnterEvent.remove(); 127 | this.regionDidExitEvent.remove(); 128 | ``` 129 | 130 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoring.ios.js#L75) 131 | -------------------------------------------------------------------------------- /examples/samples/monitoringAndRanging.android.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "monitoring + ranging beacons in Android" 2 | 3 | This documentation give a deeper explanation on how to monitor and range (at same time) beacons in Android. 4 | 5 | This documentation is linked to the sample code [monitoringAndRaging.android.js](./monitoringAndRanging.android.js) 6 | 7 | ## 1- start detection for beacon of your choice 8 | 9 | Before starting tell the library what kind of beacon you want to manage. 10 | 11 | ```javascript 12 | // dealing with iBeacons: 13 | Beacons.detectIBeacons(); 14 | ``` 15 | 16 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.android.js#L34) 17 | 18 | ## 2- start monitoring and ranging 19 | 20 | Tell Android what you want to monitor and range by defining a desired `region`. 21 | 22 | 23 | ```javascript 24 | // Define a region which can be identifier + uuid, 25 | // identifier + uuid + major or identifier + uuid + major + minor 26 | // (minor and major properties are 'OPTIONAL' numbers) 27 | const region = { identifier, uuid }; 28 | 29 | // Monitor beacons inside the region 30 | Beacons 31 | .startMonitoringForRegion(region) 32 | .then(() => console.log('Beacons monitoring started succesfully')) 33 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 34 | 35 | // Range beacons inside the region 36 | Beacons 37 | .startRangingBeaconsInRegion(identifier, uuid) 38 | .then(() => console.log('Beacons ranging started succesfully')) 39 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 40 | ``` 41 | 42 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.android.js#L36) 43 | 44 | ## 3- register events 45 | 46 | Monitoring and ranging now work. 47 | 48 | You have now to register events. 49 | 50 | ```javascript 51 | // Ranging: 52 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 53 | 'beaconsDidRange', 54 | (data) => { 55 | console.log('beaconsDidRange data: ', data); 56 | this.setState({ rangingDataSource: this.state.rangingDataSource.cloneWithRows(data.beacons) }); 57 | } 58 | ); 59 | 60 | // monitoring: 61 | this.beaconsDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 62 | 'regionDidEnter', 63 | ({ identifier, uuid, minor, major }) => { 64 | console.log('monitoring - regionDidEnter data: ', { identifier, uuid, minor, major }); 65 | const time = moment().format(TIME_FORMAT); 66 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 67 | } 68 | ); 69 | 70 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 71 | 'regionDidExit', 72 | ({ identifier, uuid, minor, major }) => { 73 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 74 | const time = moment().format(TIME_FORMAT); 75 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 76 | } 77 | ); 78 | ``` 79 | 80 | **IMPORTANT:** 81 | - **`regionDidExit` will trigger `ONLY after` a timeout of `30 seconds` when having left region (= beacons no more detected)** 82 | 83 | - **if you start the monotoring when already in region, `regionDidEnter` will not trigger first time. (leave region and wait at least 30 seconds then enter again the region)** 84 | 85 | 86 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.android.js#L54) 87 | 88 | 89 | ## 4- on componentWillUnMount: unregister events and stop monitoring 90 | 91 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 92 | 93 | Tell Android to stop monitoring at the same time. 94 | 95 | ```javascript 96 | const { uuid, identifier } = this.state; 97 | const region = { identifier, uuid }; 98 | 99 | // stop ranging beacons: 100 | Beacons 101 | .stopRangingBeaconsInRegion(identifier, uuid) 102 | .then(() => console.log('Beacons ranging stopped succesfully')) 103 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 104 | 105 | // stop monitoring beacons: 106 | Beacons 107 | .stopMonitoringForRegion(region) 108 | .then(() => console.log('Beacons monitoring stopped succesfully')) 109 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 110 | 111 | // remove ranging event we registered at componentDidMount 112 | this.beaconsDidRangeEvent.remove(); 113 | // remove beacons events we registered at componentDidMount 114 | this.regionDidEnterEvent.remove(); 115 | this.regionDidExitEvent.remove(); 116 | ``` 117 | 118 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.android.js#L87) 119 | -------------------------------------------------------------------------------- /examples/samples/monitoringAndRanging.ios.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "monitoring + ranging beacons in iOS" 2 | 3 | This documentation give a deeper explanation on how to monitor and range (at same time) beacons in iOS. 4 | 5 | This documentation is linked to the sample code [monitoringAndRanging.ios.js](./monitoringAndRanging.ios.js) 6 | 7 | ## 1- request authorization 8 | 9 | When dealing with Beacons, you technically deal with native location ([see Apple documentation](https://developer.apple.com/reference/corelocation/cllocationmanager)). 10 | 11 | Before starting ranging, iOS force you to ask for authorization in case of location services. 12 | 13 | If you don't: 14 | - it won't generate an error 15 | - but nothing will happen until you have authorization 16 | 17 | 18 | > Ranging requires lower level of authorization `WhenInUse` as for monitoring (`Always`). So you don't have the choice you have to request highest level of authorization for both: `Always` authorization wether you need background mode or not. 19 | 20 | [See matching lines in sample example]() 21 | 22 | ### 1 `Beacons.requestAlwaysAuthorization();` (**background and foreground use-case**) 23 | 24 | #### in your react native application 25 | Ensure to call 26 | 27 | ```javascript 28 | this.authStateDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 29 | 'authorizationStatusDidChange', 30 | (info) => console.log('authorizationStatusDidChange: ', info) 31 | ); 32 | ``` 33 | 34 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.ios.js#L37) 35 | 36 | #### in your iOS project 37 | 38 | To be effective your `info.plist` file should have `Privacy - Location Always Usage Description` key defined (*empty value or not. It is better to define a value to a custom / more user-friendly message*). 39 | 40 | *You have to manually `add it` to your `info.plist`:* 41 | 42 | ![ios: request when in use authorization](../../images/plistRequireAlwaysUseAutorization.png) 43 | 44 | ## 2- start monitoring and ranging 45 | 46 | > IMPORTANT: ranging and monitoring at same time will work only if you **start monitoring before ranging**. 47 | 48 | For both tell iOS what you want to range by defining a desired `region` object. 49 | 50 | 51 | ```javascript 52 | // Define a region which can be identifier + uuid, 53 | // identifier + uuid + major or identifier + uuid + major + minor 54 | // (minor and major properties are numbers) 55 | const region = { identifier, uuid }; 56 | 57 | // ALWAYS BEFORE RANGING: Monitor for beacons inside the region 58 | Beacons 59 | .startMonitoringForRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 60 | .then(() => console.log('Beacons monitoring started succesfully')) 61 | .catch(error => console.log(`Beacons monitoring not started, error: ${error}`)); 62 | // Range for beacons inside the region 63 | Beacons 64 | .startRangingBeaconsInRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 65 | .then(() => console.log('Beacons ranging started succesfully')) 66 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 67 | ``` 68 | 69 | [See matching lines in sample example]() 70 | 71 | ## 3- get the position of the device 72 | 73 | Monitoring needs you to get position of the device. 74 | 75 | Just call: 76 | ```javascript 77 | Beacons.startUpdatingLocation(); 78 | ``` 79 | 80 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.ios.js#L42) 81 | 82 | ## 4- register events 83 | 84 | Monitoring and ranging now work. 85 | 86 | You have now to register events. 87 | 88 | > Here order between events registrations for ranging and monitoring does not matter. 89 | 90 | ```javascript 91 | // Ranging: Listen for beacon changes 92 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 93 | 'beaconsDidRange', 94 | (data) => { 95 | // console.log('beaconsDidRange data: ', data); 96 | this.setState({ rangingDataSource: this.state.rangingDataSource.cloneWithRows(data.beacons) }); 97 | } 98 | ); 99 | 100 | // Monitoring: Listen for device entering the defined region 101 | this.regionDidEnterEvent = Beacons.BeaconsEventEmitter.addListener( 102 | 'regionDidEnter', 103 | (data) => { 104 | console.log('monitoring - regionDidEnter data: ', data); 105 | const time = moment().format(TIME_FORMAT); 106 | this.setState({ regionEnterDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier:data.identifier, uuid:data.uuid, minor:data.minor, major:data.major, time }]) }); 107 | } 108 | ); 109 | 110 | // Monitoring: Listen for device leaving the defined region 111 | this.regionDidExitEvent = Beacons.BeaconsEventEmitter.addListener( 112 | 'regionDidExit', 113 | ({ identifier, uuid, minor, major }) => { 114 | console.log('monitoring - regionDidExit data: ', { identifier, uuid, minor, major }); 115 | const time = moment().format(TIME_FORMAT); 116 | this.setState({ regionExitDatasource: this.state.rangingDataSource.cloneWithRows([{ identifier, uuid, minor, major, time }]) }); 117 | } 118 | ); 119 | ``` 120 | 121 | **IMPORTANT:** 122 | - **`regionDidExit` will trigger `ONLY after` a timeout of `30 seconds` when having left region (= beacons no more detected)** 123 | 124 | - **if you start the monotoring when already in region, `regionDidEnter` will not trigger first time. (leave region and wait at least 30 seconds then enter again the region)** 125 | 126 | 127 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.ios.js#L57) 128 | 129 | 130 | ## 5- on componentWillUnMount: unregister events and stop monitoring 131 | 132 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 133 | 134 | Tell iOS to stop ranging at the same time. 135 | 136 | ```javascript 137 | // stop monitoring beacons: 138 | Beacons 139 | .stopMonitoringForRegion(region) 140 | .then(() => console.log('Beacons monitoring stopped succesfully')) 141 | .catch(error => console.log(`Beacons monitoring not stopped, error: ${error}`)); 142 | // stop ranging beacons: 143 | Beacons 144 | .stopRangingBeaconsInRegion(region) 145 | .then(() => console.log('Beacons ranging stopped succesfully')) 146 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 147 | // stop updating locationManager: 148 | Beacons.stopUpdatingLocation(); 149 | 150 | this.authStateDidRangeEvent.remove(); 151 | // remove monitoring events we registered at componentDidMount 152 | this.regionDidEnterEvent.remove(); 153 | this.regionDidExitEvent.remove(); 154 | // remove ranging event we registered at componentDidMount 155 | this.beaconsDidRangeEvent.remove(); 156 | ``` 157 | 158 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/monitoringAndRanging.ios.js#L85) 159 | -------------------------------------------------------------------------------- /examples/samples/ranging.android.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import Beacons from 'react-native-beacons-manager'; 4 | import moment from 'moment'; 5 | 6 | const TIME_FORMAT = 'MM/DD/YYYY HH:mm:ss'; 7 | 8 | class beaconRangingOnly extends Component { 9 | // will be set as a reference to "beaconsDidRange" event: 10 | beaconsDidRangeEvent = null; 11 | 12 | state = { 13 | // region information 14 | uuid: '7b44b47b-52a1-5381-90c2-f09b6838c5d4', 15 | identifier: 'some id', 16 | 17 | rangingDataSource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]) 18 | }; 19 | 20 | componentWillMount(){ 21 | const { identifier, uuid } = this.state; 22 | // 23 | // ONLY non component state aware here in componentWillMount 24 | // 25 | 26 | // start iBeacon detection (later will add Eddystone and Nordic Semiconductor beacons) 27 | Beacons.detectIBeacons(); 28 | // Range beacons inside the region 29 | Beacons 30 | .startRangingBeaconsInRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 31 | .then(() => console.log('Beacons ranging started succesfully')) 32 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 33 | } 34 | 35 | componentDidMount() { 36 | // 37 | // component state aware here - attach events 38 | // 39 | 40 | // Ranging: Listen for beacon changes 41 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 42 | 'beaconsDidRange', 43 | (data) => { 44 | console.log('beaconsDidRange data: ', data); 45 | this.setState({ rangingDataSource: this.state.rangingDataSource.cloneWithRows(data.beacons) }); 46 | } 47 | ); 48 | } 49 | 50 | componentWillUnMount() { 51 | const { uuid, identifier } = this.state; 52 | // stop ranging beacons: 53 | Beacons 54 | .stopRangingBeaconsInRegion(region) // or like < v1.0.7: .stopRangingBeaconsInRegion(identifier, uuid) 55 | .then(() => console.log('Beacons ranging stopped succesfully')) 56 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 57 | 58 | // remove ranging event we registered at componentDidMount 59 | this.beaconsDidRangeEvent.remove(); 60 | } 61 | 62 | render() { 63 | const { rangingDataSource } = this.state; 64 | 65 | return ( 66 | 67 | 68 | ranging beacons in the area: 69 | 70 | 75 | 76 | ); 77 | } 78 | 79 | renderRangingRow = (rowData) => { 80 | return ( 81 | 82 | 83 | UUID: {rowData.uuid ? rowData.uuid : 'NA'} 84 | 85 | 86 | Major: {rowData.major ? rowData.major : 'NA'} 87 | 88 | 89 | Minor: {rowData.minor ? rowData.minor : 'NA'} 90 | 91 | 92 | RSSI: {rowData.rssi ? rowData.rssi : 'NA'} 93 | 94 | 95 | Proximity: {rowData.proximity ? rowData.proximity : 'NA'} 96 | 97 | 98 | Distance: {rowData.accuracy ? rowData.accuracy.toFixed(2) : 'NA'}m 99 | 100 | 101 | ); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /examples/samples/ranging.android.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "ranging beacons in Android" 2 | 3 | This documentation give a deeper explanation on how to monitor (*but ranging only*) beacons in Android. 4 | 5 | This documentation is linked to the sample code [ranging.android.js](./ranging.android.js) 6 | 7 | ## 1- start detection for beacon of your choice 8 | 9 | Before starting, tell the library what kind of beacon you want to manage. 10 | 11 | ```javascript 12 | // dealing with iBeacons: 13 | Beacons.detectIBeacons(); 14 | ``` 15 | 16 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.android.js#L27) 17 | 18 | ## 2- start ranging 19 | 20 | Tell Android what you want to range by defining a desired `region` object. 21 | 22 | 23 | ```javascript 24 | // start ranging beacons 25 | Beacons 26 | .startRangingBeaconsInRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 27 | .then(() => console.log('Beacons ranging started succesfully')) 28 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 29 | ``` 30 | 31 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.android.js#L29) 32 | 33 | ## 3- register events 34 | 35 | Monitoring now works. 36 | 37 | You have to register events to know and use about data from enter region and leave region events. 38 | 39 | ```javascript 40 | 41 | // Ranging: Listen for beacon changes 42 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 43 | 'beaconsDidRange', 44 | (data) => { 45 | console.log('beaconsDidRange data: ', data); 46 | this.setState({ rangingDataSource: this.state.rangingDataSource.cloneWithRows(data.beacons) }); 47 | } 48 | ); 49 | ``` 50 | 51 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.android.js#L42) 52 | 53 | 54 | ## 4- on componentWillUnMount: unregister event and stop ranging 55 | 56 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 57 | 58 | Tell Android to stop ranging at the same time. 59 | 60 | ```javascript 61 | 62 | // stop ranging beacons: 63 | Beacons 64 | .stopRangingBeaconsInRegion(region) // or like < v1.0.7: .stopRangingBeaconsInRegion(identifier, uuid) 65 | .then(() => console.log('Beacons ranging stopped succesfully')) 66 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 67 | 68 | // remove ranging event we registered at componentDidMount 69 | this.beaconsDidRangeEvent.remove(); 70 | ``` 71 | 72 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.android.js#L54) 73 | -------------------------------------------------------------------------------- /examples/samples/ranging.ios.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import { NativeEventEmitter } from 'react-native' 4 | import Beacons from 'react-native-beacons-manager'; 5 | import moment from 'moment'; 6 | 7 | const TIME_FORMAT = 'MM/DD/YYYY HH:mm:ss'; 8 | 9 | class beaconRangingOnly extends Component { 10 | 11 | // will be set as a reference to "beaconsDidRange" event: 12 | beaconsDidRangeEvent = null; 13 | // will be set as a reference to "authorizationStatusDidChange" event: 14 | authStateDidRangeEvent = null; 15 | 16 | state = { 17 | // region information 18 | uuid: '7b44b47b-52a1-5381-90c2-f09b6838c5d4', 19 | identifier: 'some id', 20 | 21 | rangingDataSource: new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}).cloneWithRows([]) 22 | }; 23 | 24 | componentWillMount(){ 25 | const { identifier, uuid } = this.state; 26 | // 27 | // ONLY non component state aware here in componentWillMount 28 | // 29 | 30 | // OPTIONAL: listen to authorization change 31 | this.authStateDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 32 | 'authorizationStatusDidChange', 33 | (info) => console.log('authorizationStatusDidChange: ', info) 34 | ); 35 | 36 | // MANDATORY: Request for authorization while the app is open 37 | // -> this is the authorization set by default by react-native init in the info.plist file 38 | // RANGING ONLY (this is not enough to make MONITORING working) 39 | Beacons.requestWhenInUseAuthorization(); 40 | // Define a region which can be identifier + uuid, 41 | // identifier + uuid + major or identifier + uuid + major + minor 42 | // (minor and major properties are numbers) 43 | const region = { identifier, uuid }; 44 | // Range for beacons inside the region 45 | Beacons 46 | .startRangingBeaconsInRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 47 | .then(() => console.log('Beacons ranging started succesfully')) 48 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 49 | } 50 | 51 | componentDidMount() { 52 | // 53 | // component state aware here - attach events 54 | // 55 | 56 | // Ranging: Listen for beacon changes 57 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 58 | 'beaconsDidRange', 59 | (data) => { 60 | // console.log('beaconsDidRange data: ', data); 61 | this.setState({ rangingDataSource: this.state.rangingDataSource.cloneWithRows(data.beacons) }); 62 | } 63 | ); 64 | } 65 | 66 | componentWillUnMount() { 67 | const { identifier, uuid } = this.state; 68 | const region = { identifier, uuid }; 69 | // stop ranging beacons: 70 | Beacons 71 | .stopRangingBeaconsInRegion(region) 72 | .then(() => console.log('Beacons ranging stopped succesfully')) 73 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 74 | // remove auth state event we registered at componentDidMount: 75 | this.authStateDidRangeEvent.remove(); 76 | // remove ranging event we registered at componentDidMount: 77 | this.beaconsDidRangeEvent.remove(); 78 | } 79 | 80 | render() { 81 | const { rangingDataSource } = this.state; 82 | 83 | return ( 84 | 85 | 86 | ranging beacons in the area: 87 | 88 | 93 | 94 | ); 95 | } 96 | 97 | renderRangingRow(rowData) { 98 | return ( 99 | 100 | 101 | UUID: {rowData.uuid ? rowData.uuid : 'NA'} 102 | 103 | 104 | Major: {rowData.major ? rowData.major : 'NA'} 105 | 106 | 107 | Minor: {rowData.minor ? rowData.minor : 'NA'} 108 | 109 | 110 | RSSI: {rowData.rssi ? rowData.rssi : 'NA'} 111 | 112 | 113 | Proximity: {rowData.proximity ? rowData.proximity : 'NA'} 114 | 115 | 116 | Distance: {rowData.accuracy ? rowData.accuracy.toFixed(2) : 'NA'}m 117 | 118 | 119 | ); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /examples/samples/ranging.ios.md: -------------------------------------------------------------------------------- 1 | # Fully detailed documentation for "ranging beacons in iOS" 2 | 3 | This documentation give a deeper explanation on how to range (*but ranging only*) beacons in iOS. 4 | 5 | This documentation is linked to the sample code [ranging.ios.js](./ranging.ios.js) 6 | 7 | ## 1- request authorization 8 | 9 | When dealing with Beacons, you technically deal with native location ([see Apple documentation](https://developer.apple.com/reference/corelocation/cllocationmanager)). 10 | 11 | Before starting ranging, iOS force you to ask for authorization in case of location services. 12 | 13 | If you don't: 14 | - it won't generate an error 15 | - but nothing will happen until you have authorization 16 | 17 | 18 | You can request 2 kind of authorizations depending on the use case: 19 | > Do you need background capability or not? 20 | 21 | 22 | ### 1.a `Beacons.requestWhenInUseAuthorization();` (**foreground** only use-case) 23 | 24 | #### in your react native application 25 | Ensure to call 26 | 27 | ```javascript 28 | Beacons.requestWhenInUseAuthorization(); 29 | ``` 30 | 31 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.js#L35) 32 | 33 | #### in your iOS project 34 | 35 | To be effective your `info.plist` file should have `Privacy - Location When In Use Usage Description` key defined (*empty value or not. It is better to define a value to a custom / more user-friendly message*). 36 | 37 | By chance `react-native init YOUR_APP_NAME` should have already set it for you in your `info.plist` file. 38 | 39 | *Just check it:* 40 | 41 | ![ios: request when in use authorization](../../images/plistRequireWhenInUseAutorization.png) 42 | 43 | 44 | ### 1.b `Beacons.requestAlwaysAuthorization();` (**background use-case**) 45 | 46 | #### in your react native application 47 | Ensure to call 48 | 49 | ```javascript 50 | Beacons.requestAlwaysAuthorization(); 51 | ``` 52 | 53 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.js#L35) 54 | 55 | #### in your iOS project 56 | 57 | To be effective your `info.plist` file should have `Privacy - Location Always Usage Description` key defined (*empty value or not. It is better to define a value to a custom / more user-friendly message*). 58 | 59 | *You have to manually `add it` to your `info.plist`:* 60 | 61 | ![ios: request when in use authorization](../../images/plistRequireAlwaysUseAutorization.png) 62 | 63 | ## 2- start ranging 64 | 65 | Tell iOS what you want to range by defining a desired `region` object. 66 | 67 | 68 | ```javascript 69 | // Define a region which can be identifier + uuid, 70 | // identifier + uuid + major or identifier + uuid + major + minor 71 | // (minor and major properties are numbers) 72 | const region = { identifier, uuid }; 73 | 74 | // Range for beacons inside the region 75 | Beacons 76 | .startRangingBeaconsInRegion(region) // or like < v1.0.7: .startRangingBeaconsInRegion(identifier, uuid) 77 | .then(() => console.log('Beacons ranging started succesfully')) 78 | .catch(error => console.log(`Beacons ranging not started, error: ${error}`)); 79 | ``` 80 | 81 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.js#L41) 82 | 83 | ## 3- register events 84 | 85 | Ranging now works. 86 | 87 | You have to register events to know and use about data from location updates. 88 | 89 | ```javascript 90 | 91 | // Ranging: Listen for beacon changes 92 | this.beaconsDidRangeEvent = Beacons.BeaconsEventEmitter.addListener( 93 | 'beaconsDidRange', 94 | ({region: {identifier, uuid}, beacons) => { 95 | // do here anything you need (ex: setting state...) 96 | console.log('beaconsDidRange these beacons: ', beacons); 97 | } 98 | ); 99 | ``` 100 | 101 | Note: beacons is an array of object: 102 | ```javascript 103 | 104 | { 105 | uuid, 106 | major, 107 | minor, 108 | rssi, 109 | proximity, 110 | accuracy, 111 | } 112 | ``` 113 | 114 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.js#L50) 115 | 116 | 117 | ## 4- on componentWillUnMount: unregister events and stop ranging 118 | 119 | A good practise is to ALWAYS unregister events in `componentWillUnMount`. 120 | 121 | Tell iOS to stop ranging at the same time. 122 | 123 | ```javascript 124 | const { identifier, uuid } = this.state; 125 | const region = { identifier, uuid }; 126 | // stop ranging beacons: 127 | Beacons 128 | .stopRangingBeaconsInRegion(region) 129 | .then(() => console.log('Beacons ranging stopped succesfully')) 130 | .catch(error => console.log(`Beacons ranging not stopped, error: ${error}`)); 131 | // remove beacons event we registered at componentDidMount 132 | this.beaconsDidRangeEvent.remove(); 133 | ``` 134 | 135 | [See matching lines in sample example](https://github.com/MacKentoch/react-native-beacons-manager/blob/master/examples/samples/ranging.ios.js#L61) 136 | -------------------------------------------------------------------------------- /images/RN-iBeacon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/RN-iBeacon.png -------------------------------------------------------------------------------- /images/beacons/altbeacon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/altbeacon.png -------------------------------------------------------------------------------- /images/beacons/altbeacon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/altbeacon@2x.png -------------------------------------------------------------------------------- /images/beacons/altbeacon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/altbeacon@3x.png -------------------------------------------------------------------------------- /images/beacons/eddystoneURL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystoneURL.png -------------------------------------------------------------------------------- /images/beacons/eddystoneURL@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystoneURL@2x.png -------------------------------------------------------------------------------- /images/beacons/eddystoneURL@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystoneURL@3x.png -------------------------------------------------------------------------------- /images/beacons/eddystone_TLM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_TLM.png -------------------------------------------------------------------------------- /images/beacons/eddystone_TLM@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_TLM@2x.png -------------------------------------------------------------------------------- /images/beacons/eddystone_TLM@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_TLM@3x.png -------------------------------------------------------------------------------- /images/beacons/eddystone_UID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_UID.png -------------------------------------------------------------------------------- /images/beacons/eddystone_UID@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_UID@2x.png -------------------------------------------------------------------------------- /images/beacons/eddystone_UID@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/eddystone_UID@3x.png -------------------------------------------------------------------------------- /images/beacons/ibeacon@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/ibeacon@1x.png -------------------------------------------------------------------------------- /images/beacons/ibeacon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/ibeacon@2x.png -------------------------------------------------------------------------------- /images/beacons/ibeacon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/beacons/ibeacon@3x.png -------------------------------------------------------------------------------- /images/bgmode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/bgmode.gif -------------------------------------------------------------------------------- /images/paypal/Paypal-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/paypal/Paypal-button.png -------------------------------------------------------------------------------- /images/paypal/Paypal-button@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/paypal/Paypal-button@2x.png -------------------------------------------------------------------------------- /images/paypal/Paypal-button@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/paypal/Paypal-button@3x.png -------------------------------------------------------------------------------- /images/plistRequireAlwaysUseAutorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/plistRequireAlwaysUseAutorization.png -------------------------------------------------------------------------------- /images/plistRequireWhenInUseAutorization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MacKentoch/react-native-beacons-manager/1b46895856fd4ca219501cc436380ab49da49e39/images/plistRequireWhenInUseAutorization.png -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // flow 2 | 3 | import { Platform } from 'react-native'; 4 | 5 | const RNiBeaconsModule = Platform.select({ 6 | ios: () => require('./lib/next/new.module.ios.js'), 7 | android: () => require('./lib/next/new.module.android.js'), 8 | })(); 9 | 10 | export default RNiBeaconsModule; 11 | -------------------------------------------------------------------------------- /ios/RNiBeacon/RNiBeacon/ESSBeaconScanner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | 17 | @class ESSBeaconScanner; 18 | 19 | // Delegates to the ESSBeaconScanner should implement this protocol. 20 | @protocol ESSBeaconScannerDelegate 21 | 22 | @optional 23 | 24 | - (void)beaconScanner:(ESSBeaconScanner *)scanner 25 | didRangeBeacon:(NSArray *)beacons; 26 | 27 | - (void)beaconScanner:(ESSBeaconScanner *)scanner 28 | didFindURL:(NSURL *)url; 29 | 30 | @end 31 | 32 | @interface ESSBeaconScanner : NSObject 33 | 34 | @property(nonatomic, weak) id delegate; 35 | 36 | @property(nonatomic, assign) NSTimeInterval onLostTimeout; 37 | 38 | - (void)startScanning; 39 | - (void)stopScanning; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /ios/RNiBeacon/RNiBeacon/ESSEddystone.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | #import 17 | 18 | typedef NS_ENUM(NSUInteger, ESSBeaconType) { 19 | kESSBeaconTypeEddystone = 1, 20 | kESSBeaconTypeEddystoneEID = 2, 21 | }; 22 | 23 | typedef NS_ENUM(NSUInteger, ESSFrameType) { 24 | kESSEddystoneUnknownFrameType = 0, 25 | kESSEddystoneUIDFrameType, 26 | kESSEddystoneURLFrameType, 27 | kESSEddystoneEIDFrameType, 28 | kESSEddystoneTelemetryFrameType, 29 | }; 30 | 31 | /** 32 | *=-----------------------------------------------------------------------------------------------= 33 | * ESSBeaconID 34 | *=-----------------------------------------------------------------------------------------------= 35 | */ 36 | @interface ESSBeaconID : NSObject 37 | 38 | /** 39 | * The type of the beacon. Currently only a couple of types are supported. 40 | */ 41 | @property(nonatomic, assign, readonly) ESSBeaconType beaconType; 42 | 43 | /** 44 | * The raw beaconID data. 45 | */ 46 | @property(nonatomic, copy, readonly) NSData *beaconID; 47 | 48 | @end 49 | 50 | 51 | /** 52 | *=-----------------------------------------------------------------------------------------------= 53 | * ESSBeaconInfo 54 | *=-----------------------------------------------------------------------------------------------= 55 | */ 56 | @interface ESSBeaconInfo : NSObject 57 | 58 | /** 59 | * The most recent RSSI we got for this sighting. Sometimes the OS cannot compute one reliably, so 60 | * this value can be null. 61 | */ 62 | @property(nonatomic, strong, readonly) NSNumber *RSSI; 63 | 64 | /** 65 | * The beaconID for this Eddystone. All beacons have an ID. 66 | */ 67 | @property(nonatomic, strong, readonly) ESSBeaconID *beaconID; 68 | 69 | /** 70 | * The telemetry that may or may not have been seen for this beacon. If it's set, the contents of 71 | * it aren't terribly relevant to us, in general. See the Eddystone spec for more information 72 | * if you're really interested in the exact details. 73 | */ 74 | @property(nonatomic, copy, readonly) NSData *telemetry; 75 | 76 | /** 77 | * Transmission power reported by beacon. This is in dB. 78 | */ 79 | @property(nonatomic, strong, readonly) NSNumber *txPower; 80 | 81 | /** 82 | * The scanner has seen a frame for an Eddystone. We'll need to know what type of Eddystone frame 83 | * it is, as there are a few types. 84 | */ 85 | + (ESSFrameType)frameTypeForFrame:(NSData *)frameData; 86 | 87 | /** 88 | * Given the service data for a frame we know to be a UID frame, an RSSI sighting, 89 | * and -- optionally -- telemetry data (if we've seen it), create a new ESSBeaconInfo object to 90 | * represent this Eddystone 91 | */ 92 | + (instancetype)beaconInfoForUIDFrameData:(NSData *)UIDFrameData 93 | telemetry:(NSData *)telemetry 94 | RSSI:(NSNumber *)initialRSSI; 95 | 96 | /** 97 | * Given the service data for a frame we know to be a UID frame, an RSSI sighting, 98 | * and -- optionally -- telemetry data (if we've seen it), create a new ESSBeaconInfo object to 99 | * represent this Eddystone 100 | */ 101 | + (instancetype)beaconInfoForEIDFrameData:(NSData *)EIDFrameData 102 | telemetry:(NSData *)telemetry 103 | RSSI:(NSNumber *)initialRSSI; 104 | 105 | /** 106 | * If we're given a URL frame, extract the URL from it. 107 | */ 108 | + (NSURL *)parseURLFromFrameData:(NSData *)URLFrameData; 109 | 110 | /** 111 | * Convenience method to save everybody from creating these things all the time. 112 | */ 113 | + (CBUUID *)eddystoneServiceID; 114 | 115 | + (ESSBeaconInfo *)testBeaconFromBeaconIDString:(NSString *)beaconID; 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /ios/RNiBeacon/RNiBeacon/ESSTimer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | 17 | @class ESSTimer; 18 | 19 | typedef void(^ESSTimerBlock)(ESSTimer *timer); 20 | 21 | /** 22 | *=-----------------------------------------------------------------------------------------------= 23 | * ESSTimer 24 | *=-----------------------------------------------------------------------------------------------= 25 | * A Timer class, much like NSTimer, but implemented using dispatch queues and sources. 26 | */ 27 | @interface ESSTimer : NSObject 28 | 29 | @property(nonatomic, copy, readonly) ESSTimerBlock block; 30 | @property(nonatomic, strong, readonly) dispatch_queue_t queue; 31 | @property(nonatomic, assign, readonly) NSTimeInterval delay; 32 | 33 | - (ESSTimer *)initWithDelay:(NSTimeInterval)delay 34 | onQueue:(dispatch_queue_t)queue 35 | block:(ESSTimerBlock)block; 36 | 37 | + (ESSTimer *)timerWithDelay:(NSTimeInterval)delay 38 | onQueue:(dispatch_queue_t)queue 39 | block:(ESSTimerBlock)block; 40 | 41 | + (ESSTimer *)scheduledTimerWithDelay:(NSTimeInterval)delay 42 | onQueue:(dispatch_queue_t)queue 43 | block:(ESSTimerBlock)block; 44 | 45 | /** 46 | * Schedule this timer so that it will fire after the specified delay. 47 | */ 48 | - (void)schedule; 49 | 50 | /** 51 | * Reschedule the timer, so it will fire after the specified delay from the current time, rather 52 | * than from when it was initially scheduled or last rescheduled. 53 | * This should not be called before |schedule|, though it will have no effect. 54 | */ 55 | - (void)reschedule; 56 | 57 | /** 58 | * Suspend this timer, so that it will not fire unless and until it has been resumed. 59 | */ 60 | - (void)suspend; 61 | 62 | /** 63 | * Resume the timer to allow it to fire. 64 | */ 65 | - (void)resume; 66 | 67 | /** 68 | * Cancel the timer, preventing it from ever firing again. 69 | */ 70 | - (void)cancel; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /ios/RNiBeacon/RNiBeacon/ESSTimer.m: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import "ESSTimer.h" 16 | 17 | /** 18 | *=-----------------------------------------------------------------------------------------------= 19 | * Private Additions to ESSTimer 20 | *=-----------------------------------------------------------------------------------------------= 21 | */ 22 | @interface ESSTimer () 23 | 24 | @property(nonatomic, copy, readwrite) ESSTimerBlock block; 25 | @property(nonatomic, copy, readwrite) void(^wrappedBlock)(); 26 | @property(nonatomic, strong, readwrite) dispatch_queue_t queue; 27 | @property(nonatomic, assign, readwrite) NSTimeInterval delay; 28 | 29 | // The dispatch source used for the timer. 30 | @property(nonatomic, strong, readwrite) dispatch_source_t source; 31 | 32 | @property(nonatomic, assign) BOOL suspended; 33 | 34 | @end 35 | 36 | /** 37 | *=-----------------------------------------------------------------------------------------------= 38 | * Implementation for ESSTimer 39 | *=-----------------------------------------------------------------------------------------------= 40 | */ 41 | @implementation ESSTimer 42 | 43 | - (ESSTimer *)initWithDelay:(NSTimeInterval)delay 44 | onQueue:(dispatch_queue_t)queue 45 | block:(ESSTimerBlock)block { 46 | self = [super init]; 47 | if (self) { 48 | _block = block; 49 | _queue = queue; 50 | _delay = delay; 51 | 52 | __block ESSTimer *blockSelf = self; 53 | 54 | _wrappedBlock = ^{ 55 | // This is a one-shot timer - ensure we don't call its block after it has been canceled. 56 | if (!dispatch_source_testcancel(blockSelf.source)) { 57 | dispatch_source_cancel(blockSelf.source); 58 | blockSelf.block(blockSelf); 59 | } 60 | }; 61 | 62 | _source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _queue); 63 | } 64 | return self; 65 | } 66 | 67 | + (ESSTimer *)timerWithDelay:(NSTimeInterval)delay 68 | onQueue:(dispatch_queue_t)queue 69 | block:(ESSTimerBlock)block { 70 | return [[self alloc] initWithDelay:delay onQueue:queue block:block]; 71 | 72 | } 73 | 74 | + (ESSTimer *)scheduledTimerWithDelay:(NSTimeInterval)delay 75 | onQueue:(dispatch_queue_t)queue 76 | block:(ESSTimerBlock)block { 77 | ESSTimer *timer = [self timerWithDelay:delay onQueue:queue block:block]; 78 | [timer schedule]; 79 | return timer; 80 | } 81 | 82 | - (void)schedule { 83 | [self reschedule]; 84 | dispatch_source_set_event_handler(_source, _wrappedBlock); 85 | dispatch_resume(_source); 86 | } 87 | 88 | - (void)reschedule { 89 | dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_delay * NSEC_PER_SEC)); 90 | // Leeway is 10% of timer delay 91 | dispatch_source_set_timer(_source, start, DISPATCH_TIME_FOREVER, 92 | (uint64_t)(_delay / 10) * NSEC_PER_SEC); 93 | } 94 | 95 | - (void)suspend { 96 | dispatch_suspend(_source); 97 | } 98 | 99 | - (void)resume { 100 | dispatch_resume(_source); 101 | } 102 | 103 | - (void)cancel { 104 | dispatch_source_cancel(_source); 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /ios/RNiBeacon/RNiBeacon/RNiBeacon.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNiBeacon.h 3 | // RNiBeacon 4 | // 5 | // Created by MacKentoch on 17/02/2017. 6 | // Copyright © 2017 Erwan DATIN. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | @interface RNiBeacon : RCTEventEmitter 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": [ 3 | "node_modules", 4 | "android", 5 | "ios", 6 | "images", 7 | "example" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /lib/next/module.types.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | export type BeaconRegion = { 4 | identifier: string, 5 | uuid: string, 6 | minor?: number, 7 | major?: number, 8 | proximity?: string, 9 | rssi?: number, 10 | // distance: 11 | distance?: number, // android 12 | accuracy?: number, // iOS 13 | }; 14 | 15 | // iOS only 16 | export type AuthorizationStatus = 17 | | 'authorizedAlways' 18 | | 'authorizedWhenInUse' 19 | | 'denied' 20 | | 'notDetermined' 21 | | 'restricted'; 22 | 23 | // iOS only 24 | type GetAuthorizationCallback = (status: AuthorizationStatus) => void; 25 | 26 | // android only 27 | export const PARSER_IBEACON: string = 28 | 'm:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24'; 29 | export const PARSER_ESTIMOTE: string = 30 | 'm:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24'; 31 | export const PARSER_ALTBEACON: string = 32 | 'm:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25'; 33 | export const PARSER_EDDYSTONE_TLM: string = 34 | 'x,s:0-1=feaa,m:2-2=20,d:3-3,d:4-5,d:6-7,d:8-11,d:12-15'; 35 | export const PARSER_EDDYSTONE_UID: string = 36 | 's:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19'; 37 | export const PARSER_EDDYSTONE_URL: string = 38 | 's:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v'; 39 | 40 | // android only 41 | export const transmissionSupport: Array = [ 42 | 'SUPPORTED', 43 | 'NOT_SUPPORTED_MIN_SDK', 44 | 'NOT_SUPPORTED_BLE', 45 | 'DEPRECATED_NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS', 46 | 'NOT_SUPPORTED_CANNOT_GET_ADVERTISER', 47 | 'NOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTS', 48 | ]; 49 | 50 | export type Parser = string | number; 51 | 52 | export type BeaconsManagerIOS = { 53 | // specific to iOS: 54 | requestAlwaysAuthorization: () => void, 55 | requestWhenInUseAuthorization: () => void, 56 | allowsBackgroundLocationUpdates: (allow: boolean) => void, 57 | getAuthorizationStatus: (cb: GetAuthorizationCallback) => void, 58 | getMonitoredRegions: (value?: any) => void, 59 | startUpdatingLocation: () => void, 60 | stopUpdatingLocation: () => void, 61 | shouldDropEmptyRanges: (drop: boolean) => void, 62 | 63 | // common with android: 64 | startMonitoringForRegion: (region: BeaconRegion) => void, 65 | startRangingBeaconsInRegion: (region: BeaconRegion) => void, 66 | stopMonitoringForRegion: (region: BeaconRegion) => void, 67 | stopRangingBeaconsInRegion: (region: BeaconRegion) => void, 68 | requestStateForRegion: (region: BeaconRegion) => void, 69 | }; 70 | 71 | export type BeaconsManagerANDROID = { 72 | // specific to android: 73 | setHardwareEqualityEnforced: (flag: boolean) => void, 74 | 75 | addParser: (parser: Parser, resolve: () => any, reject: () => any) => void, 76 | addParsersListToDetection: ( 77 | parsers: Array, 78 | resolve: () => any, 79 | reject: () => any, 80 | ) => void, 81 | removeParser: (parser: Parser, resolve: () => any, reject: () => any) => void, 82 | removeParsersListToDetection: ( 83 | parsers: Array, 84 | resolve: () => any, 85 | reject: () => any, 86 | ) => void, 87 | 88 | detectIBeacons: () => Promise, 89 | addIBeaconsDetection: () => Promise, 90 | removeIBeaconsDetection: () => Promise, 91 | 92 | detectAltBeacons: () => Promise, 93 | addAltBeaconsDetection: () => Promise, 94 | removeAltBeaconsDetection: () => Promise, 95 | 96 | detectAltBeacons: () => Promise, 97 | addAltBeaconsDetection: () => Promise, 98 | removeAltBeaconsDetection: () => Promise, 99 | 100 | detectEstimotes: () => Promise, 101 | addEstimotesDetection: () => Promise, 102 | removeEstimotesDetection: () => Promise, 103 | 104 | detectEddystoneUID: () => Promise, 105 | addEddystoneUIDDetection: () => Promise, 106 | removeEddystoneUIDDetection: () => Promise, 107 | 108 | detectEddystoneTLM: () => Promise, 109 | addEddystoneTLMDetection: () => Promise, 110 | removeEddystoneTLMDetection: () => Promise, 111 | 112 | detectEddystoneURL: () => Promise, 113 | addEddystoneURLDetection: () => Promise, 114 | removeEddystoneURLDetection: () => Promise, 115 | 116 | detectCustomBeaconLayout: () => Promise, 117 | addCustomBeaconLayoutDetection: () => Promise, 118 | removeCustomBeaconLayoutDetection: () => Promise, 119 | 120 | setBackgroundScanPeriod: (period: number) => void, 121 | setBackgroundBetweenScanPeriod: (period: number) => void, 122 | setForegroundScanPeriod: (period: number) => void, 123 | setRssiFilter: (filterType: number, avgModifier: number) => void, 124 | getRangedRegions: (value?: any) => void, 125 | ARMA_RSSI_FILTER: string, 126 | RUNNING_AVG_RSSI_FILTER: string, 127 | getMonitoredRegions: (value?: any) => void, 128 | checkTransmissionSupported: (status: any) => any, 129 | 130 | // common with iOS: 131 | startMonitoring: ( 132 | regionId: string, 133 | uuid: string, 134 | minor?: number, 135 | major?: number, 136 | resolve: () => any, 137 | reject: () => any, 138 | ) => void, 139 | 140 | startRanging: ( 141 | regionId: string, 142 | uuid?: string, 143 | resolve: () => any, 144 | reject: () => any, 145 | ) => void, 146 | 147 | stopMonitoring: ( 148 | regionId: string, 149 | uuid: string, 150 | minor?: number, 151 | major?: number, 152 | resolve: () => any, 153 | reject: () => any, 154 | ) => void, 155 | 156 | stopRanging: ( 157 | regionId: string, 158 | uuid?: string, 159 | resolve: () => any, 160 | reject: () => any, 161 | ) => void, 162 | 163 | requestStateForRegion: ( 164 | regionId: string, 165 | uuid?: string, 166 | minor?: number, 167 | major?: number, 168 | ) => void, 169 | }; 170 | -------------------------------------------------------------------------------- /lib/next/new.module.ios.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const RN = require('react-native'); 4 | 5 | import { 6 | type BeaconRegion, 7 | type AuthorizationStatus, 8 | type BeaconsManagerIOS, 9 | } from './module.types'; 10 | 11 | const BeaconsManager: BeaconsManagerIOS = RN.NativeModules.RNiBeacon; 12 | const BeaconsEventEmitter = BeaconsManager && new RN.NativeEventEmitter(BeaconsManager) || undefined; 13 | 14 | /** 15 | * request always authorization (mandatory when ranging beacons but energy drain) 16 | * IMPORTANT: To be effective your info.plist file should have 'Privacy - Location Always Usage Description' key defined 17 | */ 18 | function requestAlwaysAuthorization(): void { 19 | BeaconsManager.requestAlwaysAuthorization(); 20 | } 21 | 22 | /** 23 | * request when app in use authorization (bare minimum for beacons) 24 | * IMPORTANT: To be effective your info.plist file should have 'Privacy - Location When In Use Usage Description' key defined (hopefully 'react-native init' should have set it for you) 25 | */ 26 | function requestWhenInUseAuthorization(): void { 27 | BeaconsManager.requestWhenInUseAuthorization(); 28 | } 29 | 30 | /** 31 | * set background location updates to ensure monitoring when app is killed or in background mode 32 | * 33 | * @param {boolean} [allow=false] allow or disallow background modes 34 | */ 35 | function allowsBackgroundLocationUpdates(allow: boolean = false): void { 36 | BeaconsManager.allowsBackgroundLocationUpdates(allow); 37 | } 38 | 39 | /** 40 | * get authorization status 41 | * 42 | * @returns {() => AuthorizationStatus} instant callback (not async) 43 | */ 44 | function getAuthorizationStatus( 45 | callback: (status: AuthorizationStatus) => any, 46 | ): any { 47 | return BeaconsManager.getAuthorizationStatus(callback); 48 | } 49 | 50 | /** 51 | * get monitored regions 52 | * 53 | * @returns {Promise>} promise resolve to an array of monitored regions 54 | */ 55 | function getMonitoredRegions(): Promise> { 56 | return new Promise((resolve, reject) => { 57 | BeaconsManager.getMonitoredRegions(resolve); 58 | }); 59 | } 60 | 61 | /** 62 | * call is needed for monitoring beacons and gets the initial position of the device. 63 | * 64 | */ 65 | function startUpdatingLocation(): void { 66 | BeaconsManager.startUpdatingLocation(); 67 | } 68 | 69 | /** 70 | * This method should be called when you don't need to receive location-based information and want to save battery power. 71 | * 72 | */ 73 | function stopUpdatingLocation(): void { 74 | BeaconsManager.stopUpdatingLocation(); 75 | } 76 | 77 | function shouldDropEmptyRanges(drop: boolean): void { 78 | BeaconsManager.shouldDropEmptyRanges(drop); 79 | } 80 | 81 | /** 82 | * start monitoring for a region 83 | * 84 | * @param {BeaconRegion} region region to monitor (identifier + uuid -> major and minor are optional) 85 | * @returns {Promise} promise resolves to void or error 86 | */ 87 | function startMonitoringForRegion(region: BeaconRegion): Promise { 88 | return new Promise((resolve, reject) => { 89 | try { 90 | BeaconsManager.startMonitoringForRegion(region); 91 | resolve(); 92 | } catch (error) { 93 | reject(error); 94 | } 95 | }); 96 | } 97 | 98 | /** 99 | * stop monitoring for a region 100 | * 101 | * @param {BeaconRegion} region region (identifier + uuid -> major and minor are optional) 102 | * @returns {Promise} promise resolves to void or error 103 | */ 104 | function stopMonitoringForRegion(region: BeaconRegion): Promise { 105 | return new Promise((resolve, reject) => { 106 | try { 107 | BeaconsManager.stopMonitoringForRegion(region); 108 | resolve(); 109 | } catch (error) { 110 | reject(error); 111 | } 112 | }); 113 | } 114 | 115 | /** 116 | * start ranging for a region 117 | * 118 | * @param {BeaconRegion} region region to scan (identifier + uuid -> major and minor are optional) 119 | * @returns {Promise} promise resolves to void or error 120 | */ 121 | function startRangingBeaconsInRegion(region: BeaconRegion): Promise { 122 | return new Promise((resolve, reject) => { 123 | try { 124 | BeaconsManager.startRangingBeaconsInRegion(region); 125 | resolve(); 126 | } catch (error) { 127 | reject(error); 128 | } 129 | }); 130 | } 131 | 132 | /** 133 | * stop ranging for a region 134 | * 135 | * @param {BeaconRegion} region region (identifier + uuid -> major and minor are optional) 136 | * @returns {Promise} promise: resolves to void when successful 137 | */ 138 | function stopRangingBeaconsInRegion(region: BeaconRegion): Promise { 139 | return new Promise((resolve, reject) => { 140 | try { 141 | BeaconsManager.stopRangingBeaconsInRegion(region); 142 | resolve(); 143 | } catch (error) { 144 | reject(error); 145 | } 146 | }); 147 | } 148 | 149 | /** 150 | * Retrieves the state of a region asynchronously. 151 | * 152 | * @param {BeaconRegion} region region (identifier + uuid -> major and minor are optional) 153 | */ 154 | function requestStateForRegion(region: BeaconRegion): void { 155 | BeaconsManager.requestStateForRegion(region); 156 | } 157 | 158 | module.exports = { 159 | BeaconsEventEmitter, 160 | 161 | requestAlwaysAuthorization, 162 | requestWhenInUseAuthorization, 163 | allowsBackgroundLocationUpdates, 164 | getAuthorizationStatus, 165 | getMonitoredRegions, 166 | startUpdatingLocation, 167 | stopUpdatingLocation, 168 | shouldDropEmptyRanges, 169 | 170 | // common with android: 171 | startMonitoringForRegion, 172 | startRangingBeaconsInRegion, 173 | stopMonitoringForRegion, 174 | stopRangingBeaconsInRegion, 175 | requestStateForRegion, 176 | }; 177 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-beacons-manager", 3 | "version": "1.1.0", 4 | "description": "React-Native library for detecting beacons (iOS and Android)", 5 | "keywords": [ 6 | "react-native", 7 | "react-component", 8 | "ios", 9 | "ibeacon", 10 | "beacon", 11 | "beacons", 12 | "android", 13 | "ibeacons", 14 | "altbeacon", 15 | "estimote", 16 | "eddystone", 17 | "altbeacons" 18 | ], 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MacKentoch/react-native-beacons-manager.git" 22 | }, 23 | "typescript": { 24 | "definition": "typings/react-native-beacons-manager.d.ts" 25 | }, 26 | "types": "typings/react-native-beacons-manager.d.ts", 27 | "bugs": { 28 | "url": "https://github.com/MacKentoch/react-native-beacons-manager/issues" 29 | }, 30 | "homepage": "https://github.com/MacKentoch/react-native-beacons-manager#readme", 31 | "main": "index.js", 32 | "directories": { 33 | "example": "examples", 34 | "lib": "lib" 35 | }, 36 | "engines": { 37 | "node": ">=8.9.0", 38 | "npm": ">=5.3.0", 39 | "yarn": ">=1.5.1" 40 | }, 41 | "scripts": { 42 | "test": "echo \"Error: no test specified\" && exit 1", 43 | "flow": "node_modules/.bin/flow", 44 | "flow-typed": "node_modules/.bin/flow-typed" 45 | }, 46 | "author": "Erwan DATIN (http://www.erwan-datin.com)", 47 | "license": "MIT", 48 | "nativePackage": true, 49 | "devDependencies": { 50 | "babel-cli": "^6.24.1", 51 | "babel-eslint": "^7.2.3", 52 | "eslint": "^4.4.1", 53 | "eslint-plugin-flowtype": "^2.35.0", 54 | "eslint-plugin-react": "^7.2.0", 55 | "eslint-plugin-react-native": "^3.0.1", 56 | "flow-bin": "^0.85.0", 57 | "prop-types": "^15.5.10", 58 | "react": "^15.4.2", 59 | "react-native": "^0.61.5" 60 | }, 61 | "peerDependencies": { 62 | "react": ">=15.4.2", 63 | "react-native": ">=0.41.2" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-beacons-manager", 3 | "dependencies": {}, 4 | "globalDependencies": { 5 | "node": "registry:dt/node#7.0.0+20170322231424" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /typings/react-native-beacons-manager.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'react-native-beacons-manager' { 2 | 3 | export interface BeaconRegion { 4 | identifier: string, 5 | uuid: string, 6 | minor?: number, 7 | major?: number 8 | } 9 | 10 | export type AuthorizationStatus = 11 | | 'authorizedAlways' 12 | | 'authorizedWhenInUse' 13 | | 'denied' 14 | | 'notDetermined' 15 | | 'restricted'; 16 | 17 | class Beacons { 18 | /////////////////////////////////////////////////////// 19 | // iOS only 20 | /////////////////////////////////////////////////////// 21 | 22 | requestAlwaysAuthorization(): void; 23 | 24 | requestWhenInUseAuthorization(): void; 25 | 26 | allowsBackgroundLocationUpdates( 27 | allow: boolean 28 | ): void; 29 | 30 | getAuthorizationStatus( 31 | callback: (status: AuthorizationStatus) => any 32 | ): any; 33 | 34 | startUpdatingLocation(): void; 35 | 36 | stopUpdatingLocation(): void; 37 | 38 | shouldDropEmptyRanges( 39 | drop: boolean 40 | ): void; 41 | 42 | /////////////////////////////////////////////////////// 43 | // android only 44 | /////////////////////////////////////////////////////// 45 | ARMA_RSSI_FILTER: string; 46 | RUNNING_AVG_RSSI_FILTER: string; 47 | PARSER_IBEACON: string; 48 | PARSER_ESTIMOTE: string; 49 | PARSER_ALTBEACON: string; 50 | PARSER_EDDYSTONE_TLM: string; 51 | PARSER_EDDYSTONE_UID: string; 52 | PARSER_EDDYSTONE_URL: string; 53 | 54 | setHardwareEqualityEnforced( 55 | flag: boolean 56 | ): void; 57 | 58 | detectIBeacons(): void; 59 | 60 | detectAltBeacons(): void; 61 | 62 | detectEstimotes(): void; 63 | 64 | detectEddystoneUID(): void; 65 | 66 | detectEddystoneURL(): void; 67 | 68 | detectEddystoneTLM(): void; 69 | 70 | detectCustomBeaconLayout( 71 | parser: number 72 | ): void; 73 | 74 | setBackgroundScanPeriod( 75 | period: number 76 | ): void; 77 | 78 | setBackgroundBetweenScanPeriod( 79 | period: number 80 | ): void; 81 | 82 | setForegroundScanPeriod( 83 | period: number 84 | ): void; 85 | 86 | setRssiFilter( 87 | filterType: number, 88 | avgModifier: number 89 | ): void; 90 | 91 | getRangedRegions(): Promise; 92 | 93 | getMonitoredRegions(): Promise>; 94 | 95 | checkTransmissionSupported(): Promise; 96 | 97 | /////////////////////////////////////////////////////// 98 | // common iOS and Android 99 | /////////////////////////////////////////////////////// 100 | 101 | startMonitoringForRegion( 102 | region: BeaconRegion 103 | ): Promise; 104 | 105 | /** IOS ONLY */ 106 | startRangingBeaconsInRegion( 107 | region: BeaconRegion 108 | ): Promise; 109 | 110 | /** ANDROID ONLY */ 111 | startRangingBeaconsInRegion( 112 | // We can't simply reuse BeaconRegion as BeaconRegion.uuid is mandatory, whereas the uuid in this method is optional 113 | region: { 114 | identifier: string, 115 | uuid?: string 116 | } 117 | ): Promise; 118 | 119 | /** ANDROID ONLY */ 120 | startRangingBeaconsInRegion( 121 | regionId: string, 122 | beaconsUUID?: string 123 | ): Promise; 124 | 125 | stopMonitoringForRegion( 126 | region: BeaconRegion 127 | ): Promise; 128 | 129 | /** IOS ONLY */ 130 | stopRangingBeaconsInRegion( 131 | region: BeaconRegion 132 | ): Promise; 133 | 134 | /** ANDROID ONLY */ 135 | stopRangingBeaconsInRegion( 136 | regionId: string, 137 | beaconsUUID?: string 138 | ): Promise; 139 | 140 | /** ANDROID ONLY */ 141 | stopRangingBeaconsInRegion( 142 | // We can't simply reuse BeaconRegion as BeaconRegion.uuid is mandatory, whereas the uuid in this method is optional 143 | region: { 144 | identifier: string, 145 | uuid?: string 146 | } 147 | ): Promise; 148 | 149 | requestStateForRegion( 150 | region: BeaconRegion 151 | ): void; 152 | } 153 | 154 | const beacons: Beacons; 155 | export default beacons; 156 | } 157 | --------------------------------------------------------------------------------