Skip to content

Commit

Permalink
- flag to turn on/off testing code, turning off by default before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rodvar committed Dec 10, 2024
1 parent 9dce84b commit 7a4c106
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import kotlin.random.Random
open class MainPresenter(private val notificationServiceController: NotificationServiceController) :
BasePresenter(null), AppPresenter {
companion object {
// FIXME this will be erased eventually, for now you can turn on to see the notifications working
// it will push a notification every 60 sec
const val testNotifications = false
const val PUSH_DELAY = 60000L
}

Expand Down Expand Up @@ -57,13 +60,15 @@ open class MainPresenter(private val notificationServiceController: Notification
super.onViewAttached()
notificationServiceController.startService()
// sample code for push notifications sends a random message every 10 secs
CoroutineScope(BackgroundDispatcher).launch {
while (notificationServiceController.isServiceRunning()) {
val randomTitle = "Title ${Random.nextInt(1, 100)}"
val randomMessage = "Message ${Random.nextInt(1, 100)}"
notificationServiceController.pushNotification(randomTitle, randomMessage)
log.d {"Pushed: $randomTitle - $randomMessage" }
delay(PUSH_DELAY) // 1 min
if (testNotifications) {
backgroundScope.launch {
while (notificationServiceController.isServiceRunning()) {
val randomTitle = "Title ${Random.nextInt(1, 100)}"
val randomMessage = "Message ${Random.nextInt(1, 100)}"
notificationServiceController.pushNotification(randomTitle, randomMessage)
log.d {"Pushed: $randomTitle - $randomMessage" }
delay(PUSH_DELAY) // 1 min
}
}
}
}
Expand Down

0 comments on commit 7a4c106

Please sign in to comment.