expo-notifications 0.28.8 → 0.28.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.28.9 — 2024-06-12
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 0.28.8 — 2024-06-10
14
18
 
15
19
  ### 🐛 Bug fixes
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '0.28.8'
4
+ version = '0.28.9'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.notifications"
15
15
  defaultConfig {
16
16
  versionCode 21
17
- versionName '0.28.8'
17
+ versionName '0.28.9'
18
18
  }
19
19
 
20
20
  buildFeatures {
@@ -12,7 +12,12 @@ object BadgeHelper {
12
12
 
13
13
  fun setBadgeCount(context: Context, badgeCount: Int): Boolean {
14
14
  return try {
15
- ShortcutBadger.applyCountOrThrow(context.applicationContext, badgeCount)
15
+ if (badgeCount == 0) {
16
+ val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager
17
+ notificationManager.cancelAll()
18
+ } else {
19
+ ShortcutBadger.applyCountOrThrow(context.applicationContext, badgeCount)
20
+ }
16
21
  BadgeHelper.badgeCount = badgeCount
17
22
  true
18
23
  } catch (e: ShortcutBadgeException) {
@@ -126,16 +126,27 @@ public class NotificationManager implements SingletonModule, expo.modules.notifi
126
126
  }
127
127
  }
128
128
 
129
- public void onNotificationResponseFromExtras(Bundle extras) {
130
- if (mPendingNotificationResponsesFromExtras.isEmpty()) {
131
- mPendingNotificationResponsesFromExtras.add(extras);
132
- } else {
129
+ public void onNotificationResponseFromExtras(Bundle extras) {
130
+ // We're going to be passed in extras from either
131
+ // a killed state (ExpoNotificationLifecycleListener::onCreate)
132
+ // OR a background state (ExpoNotificationLifecycleListener::onNewIntent)
133
+
134
+ // If we've just come from a background state, we'll have listeners set up
135
+ // pass on the notification to them
136
+ if (!mListenerReferenceMap.isEmpty()) {
133
137
  for (WeakReference<NotificationListener> listenerReference : mListenerReferenceMap.values()) {
134
138
  NotificationListener listener = listenerReference.get();
135
139
  if (listener != null) {
136
140
  listener.onNotificationResponseIntentReceived(extras);
137
141
  }
138
142
  }
143
+ } else {
144
+ // Otherwise, the app has been launched from a killed state, and our listeners
145
+ // haven't yet been setup. We'll add this to a list of pending notifications
146
+ // for them to process once they've been initialized.
147
+ if (mPendingNotificationResponsesFromExtras.isEmpty()) {
148
+ mPendingNotificationResponsesFromExtras.add(extras);
149
+ }
139
150
  }
140
151
  }
141
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-notifications",
3
- "version": "0.28.8",
3
+ "version": "0.28.9",
4
4
  "description": "Notifications module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "peerDependencies": {
56
56
  "expo": "*"
57
57
  },
58
- "gitHead": "2893e9cba95261919532de0675468c601b87b017"
58
+ "gitHead": "247b0bf49d46697632665ef49660fea7a34ec174"
59
59
  }