Add the below line to your build.gradle file,
implementation 'com.oneupconnect:sdk:1.0.0'
If you are using Gradle version below
3.0.0
then you should usecompile
instead ofimplementation
.
Add or check you have this permissions in the manifest file,
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
...
<application ...>
<receiver android:name="com.oneupconnect.receiver.BluetoothStateReceiver">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED"/>
</intent-filter>
</receiver>
<receiver android:name="com.oneupconnect.receiver.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name="com.oneupconnect.service.BeaconsMonitoringService"
android:enabled="true">
</service>
...
</application>
</manifest>
To be able to work correctly, the user must have:
- the bluethooth turned ON
- allowed the Location permision
You have to validate them and include screen/dialog to inform and suggest the users to enable them as often as possible.
Extends Application and add it to start the monitoring:
import com.oneupconnect.service.BeaconsMonitoringService;
...
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
BeaconsMonitoringService.setAppToken("YOUR_API_KEY");
startService(new Intent(this, BeaconsMonitoringService.class));
}
}
To run the example project, clone the repo, and run pod install
from the Example directory.