I have kontakt.io beacon and I try to write application for background scanning with nearby API.
I use this method to subscribe messages:
SubscribeOptions options = new SubscribeOptions.Builder()
// Finds messages attached to BLE beacons. See
// https://developers.google.com/beacons/
.setStrategy(Strategy.BLE_ONLY)
.build();
Nearby.Messages.subscribe(mGoogleApiClient, getPendingIntent(), options)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "subscribed successfully");
mSubState = SubState.SUBSCRIBING;
// Start background service for handling the notification.
getActivity().startService(getBackgroundSubscribeServiceIntent());
} else {
Log.i(TAG, "could not subscribe");
handleUnsuccessfulNearbyResult(status);
}
}
});
My code is according to this sample: https://github.com/googlesamples/android-nearby/tree/master/messages/NearbyBackgroundBeacons
I´m receiving messages correctly, but when I kill application no more message come.
Is there any way to get messages from nearby after killing application?