Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/src/org/commcare/activities/PushNotificationActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.commcare.dalvik.databinding.ActivityPushNotificationBinding
import org.commcare.google.services.analytics.AnalyticsParamValue
import org.commcare.google.services.analytics.CCAnalyticsParam
import org.commcare.google.services.analytics.FirebaseAnalyticsUtil
import org.commcare.pn.helper.NotificationBroadcastHelper
import org.commcare.preferences.NotificationPrefs
import org.commcare.utils.FirebaseMessagingUtil.getIntentForPNClick

Expand All @@ -30,6 +31,7 @@ class PushNotificationActivity : AppCompatActivity() {
setContentView(binding.root)
initViews()
observeRetrieveNotificationApi()
registerForNewNotification()
pushNotificationViewModel.loadNotifications(isRefreshed = false)
}

Expand Down Expand Up @@ -113,4 +115,13 @@ class PushNotificationActivity : AppCompatActivity() {

else -> super.onOptionsItemSelected(item)
}

fun registerForNewNotification() {
NotificationBroadcastHelper.registerForNotifications(this, this) {
// Whenever new notification is received, signalling is calling retrieve_notifications api
// so whenever this broadcast is received, new notification is already stored in local DB
// that's the reason that isRefreshed = false is required
pushNotificationViewModel.loadNotifications(false)
}
}
}