I am working on an app where i have to implement a feature that when user enters a particular range or location with particular radius like in Geofence. Then it should send notification which is also in client app not FCM. I have tried multiple solution but its not working. since Android O . Background task limitation. How to implement this feature without Foreground otherwise it would seem annoying? Please If anyone have any idea Do reply. Thanks in Advance.
Code for Client
geofencingClient.addGeofences( geoFencingReq(location!!.latitude,location.longitude,name), geofencePendingIntent)
Pending Intent ->
val geofencePendingIntent: PendingIntent by lazy {
val intent = Intent(contextt, GeofenceTransitionsIntentService::class.java)
// We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling
// addGeofences() and removeGeofences().
PendingIntent.getService(contextt, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
I have updated the code which i have used but it doesnt work still when app is killed.
By registering the Geofence with the Google API they automatically also get called from the background. You can find it in com.google.android.gms.location
.
GeofencingClient.addGeofences(GeofencingRequest, PendingIntent)
is what you need.