diff --git a/README.md b/README.md index fd33cef..5d498cb 100644 --- a/README.md +++ b/README.md @@ -13,53 +13,55 @@ Please refer to the API documentation on the [Beaconstac developer hub](https:// 1. Download or clone this repo on your system. 2. Copy the [beaconstac-release.aar](https://github.com/Beaconstac/Android-SDK/blob/master/BeaconstacSDK/beaconstac-release.aar) file into the `libs` directory of your app. Refer the included sample app for example. 3. In the `build.gradle` file of your project, add the following in the repositories section - - flatDir { - dirs 'libs' - } +```groovy +flatDir { + dirs 'libs' +} +``` ![](images/repositories.png "Repositories") 4. In the `build.gradle` file of the app, add the following in the dependencies section: - - compile (name: 'beaconstac-release', ext: 'aar') - compile 'com.mcxiaoke.volley:library:1.0.17' - compile 'com.google.android.gms:play-services:8.1.0' - compile 'com.crittercism:crittercism-android-agent:5.0.6' +```groovy +compile (name: 'beaconstac-release', ext: 'aar') +compile 'com.mcxiaoke.volley:library:1.0.17' +compile 'com.google.android.gms:play-services:8.1.0' +compile 'com.crittercism:crittercism-android-agent:5.0.6 +``` 5. Refresh all Gradle projects. 6. Create a file `beaconstac.xml` in the `values` folder containing configurations for Beaconstac SDK. - - - - - true - - - 86400 - - - - CAMPED - EXITED - - - - true - - - 900 - - - true - - - - - - 0 - - - com.mobstac.beaconstacexample.provider - - +```xml + + + + true + + + 86400 + + + + CAMPED + EXITED + + + + true + + + 900 + + + true + + + + + + 0 + + + com.mobstac.beaconstacexample.provider + +``` 7. Note : Please do ensure that the organization_id and the api_key have been filled into the beaconstac.xml. @@ -67,64 +69,73 @@ Please refer to the API documentation on the [Beaconstac developer hub](https:// If this is not set, the rules will not get triggered. 8. Add `uses-feature` tag to app manifest: - - +```xml + +``` 9. Add the following permissions to app manifest: - - - - - - - +```xml + + + + + + +``` 10. Add the Beaconstac BLEService to your app manifest: - - +```xml + +``` 11. Should you choose to implement your own BroadcastReceiver (required if beacon detection has to work when the app is not running), extend `com.mobstac.beaconstac.core.BeaconstacReceiver` class and implement methods to handle the `rangedBeacons`, `campedOnBeacon`, `exitedBeacon`, `triggeredRule`, `enteredRegion` and `exitedRegion` events. The `BeaconstacExample` app contains an example of each type - directly using `BeaconstacReceiver` in the activity (this will require registering and unregistering it to receive intents in the activity itself), and extending `BeaconstacReceiver` and registering it to receive `actions` declared in the app manifest. 12. Add the Beaconstac-provided actions in the app manifest that you wish to listen for, in your BroadcastReceiver. From the `BeaconstacExample` app manifest: - - - - - - - - - - - - - +```xml + + + + + + + + + + + + +``` 13. Add `provider` to the manifest. Please implement your own ContentProvider that extends `com.mobstac.beaconstac.provider.MSContentProvider`. From the `BeaconstacExample` app: - - +```xml + +``` 14. To monitor beacon regions, configure the `UUID` and `region_identifier`. - - // set region parameters (UUID and unique region identifier) - Beaconstac bstacInstance = Beaconstac.getInstance(this); - bstacInstance.setRegionParams("F94DBB23-2266-7822-3782-57BEAC0952AC", - "com.mobstac.beaconstacexample"); +```java +// set region parameters (UUID and unique region identifier) +Beaconstac bstacInstance = Beaconstac.getInstance(this); +bstacInstance.setRegionParams("F94DBB23-2266-7822-3782-57BEAC0952AC", + "com.mobstac.beaconstacexample"); +``` 15. Call `startRangingBeacons` on the `Beaconstac` instance after configuring the params as mentioned in the previous step. The method will throw `MSException` on devices running Androi 17 or below. - - // start scanning - bstacInstance.startRangingBeacons(); +```java +// start scanning +bstacInstance.startRangingBeacons(); +``` 16. If you want to stop scanning for beacons, call `stopRangingBeacons` on the `Beaconstac` instance. The method will throw `MSException` on devices running Androi 17 or below. - - // stop scanning - bstacInstance.stopRangingBeacons(); +```java +// stop scanning +bstacInstance.stopRangingBeacons(); +``` 17. You can also dynamically set `organization_id` and `api_key` using `setOrgId` and `setDevToken` methods on the `Beaconstac` instance. 18. Add `MSGeofenceTransitionIntentService` to manifest if you want to use the SDK's Geofence APIs. - - +```xml + +``` 19. Implement the `PlaceSyncReceiver` before calling `enableGeofences` on the `Beaconstac` instance. You can find more information and example usage in the `BeaconstacExample` app contained in the `examples` directory of this repo.