Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Scout4all committed Feb 27, 2023
1 parent 339ca62 commit 769559a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified app-apk/app-debug.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,9 @@ class GeofenceBroadcastReceiver : BroadcastReceiver() {
Timber.e("GeoFence ${intent.extras.toString()}")
if (intent.action == ACTION_GEOFENCE_EVENT) {
val geofencingEvent: GeofencingEvent? = GeofencingEvent.fromIntent(intent)

if (geofencingEvent != null) {
if (geofencingEvent.hasError()) {
Timber.e(geofencingEvent.errorCode.toString())
return
GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
}


Timber.e(geofencingEvent.triggeringGeofences.toString())

if (geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {

GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
}
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,26 @@ class GeofenceTransitionsJobIntentService : JobIntentService(), CoroutineScope {
return
}
Timber.e(geofencingEvent.triggeringGeofences.toString())
if (geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
val triggeredGeofence = geofencingEvent.triggeringGeofences
if(!triggeredGeofence.isNullOrEmpty()) {
sendNotification(triggeredGeofence.first())
}

when (geofencingEvent.geofenceTransition) {
Geofence.GEOFENCE_TRANSITION_ENTER -> {
sendNotification(geofencingEvent.triggeringGeofences!!)

}
}


}

//TODO: get the request id of the current geofence
private fun sendNotification(triggeringGeofences: List<Geofence>) {
var requestId = ""

for (geofence in triggeringGeofences) {
Timber.e(geofence.requestId)
requestId = geofence.requestId
}
//Get the local repository instance
private fun sendNotification(geofence: Geofence) {
//Get the local repository instance
val remindersLocalRepository: ReminderDataSource by inject()
// Interaction to the repository has to be through a coroutine scope
CoroutineScope(coroutineContext).launch(SupervisorJob()) {
//get the reminder with the request id

val result = remindersLocalRepository.getReminder(requestId)
val result = remindersLocalRepository.getReminder(geofence.requestId)
if (result is Result.Success<ReminderDTO>) {
val reminderDTO = result.data
//send a notification to the user with the reminder details
Expand Down

0 comments on commit 769559a

Please sign in to comment.