I have a very small usecase. User A uses Google-Maps and saves geofence co-ordinates for User B. Now I am using Firebase to save all the information related to this geofence and then my app-server sends all the geofence related data to User B's phone. However, I do not understand how to set the Geofence from Firebase Messaging Service
without calling the GoogleMapsActivity
. I would like to do it in the background. I tried to search a lot on this topic on the internet. But all the tutorials don't cover this area. If anyone can share and guide me on this problem that will be a big help.
If I understand you well, you want to add some geofences in background service. Of course you can do it, just create a brand, new intent service to do that and pass required data to it.
Your service should implements GoogleApiClient.ConnectionCallbacks
, GoogleApiClient.OnConnectionFailedListener
interfaces and inside onCreate
method create GoogleApiClient
object.
Inside onHandleIntent
you should connect to GoogleApiClient
and then inside onConnected
callback method from GoogleApiClient.ConnectionCallbacks
register your geofences.
To prevent the service from stopping when performing asynchronous registration methods, you can use CountDownLatch.
Some additional infos about geofences.