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 {
removeNotificationsnull10   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 {
<lambda>null30     val instance by lazy {
31       PushNotificationHelper()
32     }
33   }
34 }
35