xref: /expo/android/expoview/src/main/java/host/exp/exponent/notifications/PushNotificationHelper.kt (revision bb5069cd)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package host.exp.exponent.notifications
2 
3 import android.content.Context
4 import androidx.core.app.NotificationManagerCompat
5 import org.json.JSONArray
6 import org.json.JSONException
7 import org.json.JSONObject
8 
9 class PushNotificationHelper {
10   fun removeNotifications(context: Context, unreadNotifications: JSONArray?) {
11     if (unreadNotifications == null) {
12       return
13     }
14 
15     val notificationManager = NotificationManagerCompat.from(context)
16     for (i in 0 until unreadNotifications.length()) {
17       try {
18         notificationManager.cancel(
19           (unreadNotifications[i] as JSONObject).getString(
20             NotificationConstants.NOTIFICATION_ID_KEY
21           ).toInt()
22         )
23       } catch (e: JSONException) {
24         e.printStackTrace()
25       }
26     }
27   }
28 
29   companion object {
30     val instance by lazy {
31       PushNotificationHelper()
32     }
33   }
34 }
35 

served by {OpenGrok

Last Index Update: Tue Oct 21 18:42:31 GMT 2025