expo-notifications 0.28.10 → 0.28.11

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,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.28.11 — 2024-07-22
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Fix serialization of vibration pattern. ([#30495](https://github.com/expo/expo/pull/30495) by [@douglowder](https://github.com/douglowder))
18
+
13
19
  ## 0.28.10 — 2024-07-15
14
20
 
15
21
  ### 🐛 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.10'
4
+ version = '0.28.11'
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.10'
17
+ versionName '0.28.11'
18
18
  }
19
19
 
20
20
  buildFeatures {
@@ -82,11 +82,7 @@ public class NotificationSerializer {
82
82
  serializedContent.putString("priority", content.getPriority().getEnumValue());
83
83
  }
84
84
  if (content.getVibrationPattern() != null) {
85
- double[] serializedVibrationPattern = new double[content.getVibrationPattern().length];
86
- for (int i = 0; i < serializedVibrationPattern.length; i++) {
87
- serializedVibrationPattern[i] = content.getVibrationPattern()[i];
88
- }
89
- serializedContent.putDoubleArray("vibrationPattern", serializedVibrationPattern);
85
+ serializedContent.putIntArray("vibrationPattern", RemoteMessageSerializer.intArrayFromLongArray(content.getVibrationPattern()));
90
86
  }
91
87
  serializedContent.putBoolean("autoDismiss", content.isAutoDismiss());
92
88
  if (content.getCategoryId() != null) {
@@ -93,7 +93,9 @@ public class RemoteMessageSerializer {
93
93
  serializedNotification.putString("title", notification.getTitle());
94
94
  serializedNotification.putStringArray("titleLocalizationArgs", notification.getTitleLocalizationArgs());
95
95
  serializedNotification.putString("titleLocalizationKey", notification.getTitleLocalizationKey());
96
- serializedNotification.putLongArray("vibrateTimings", notification.getVibrateTimings());
96
+ if (notification.getVibrateTimings() != null) {
97
+ serializedNotification.putIntArray("vibrateTimings", intArrayFromLongArray(notification.getVibrateTimings()));
98
+ }
97
99
  if (notification.getVisibility() != null) {
98
100
  serializedNotification.putInt("visibility", notification.getVisibility());
99
101
  } else {
@@ -101,4 +103,12 @@ public class RemoteMessageSerializer {
101
103
  }
102
104
  return serializedNotification;
103
105
  }
106
+
107
+ public static int[] intArrayFromLongArray(long[] longArray) {
108
+ int[] intArray = new int[longArray.length];
109
+ for (int i = 0; i < longArray.length; i++) {
110
+ intArray[i] = (int)(longArray[i]);
111
+ }
112
+ return intArray;
113
+ }
104
114
  }
@@ -12,6 +12,7 @@ import expo.modules.notifications.notifications.model.triggers.FirebaseNotificat
12
12
  import expo.modules.notifications.service.NotificationsService
13
13
  import expo.modules.notifications.service.interfaces.FirebaseMessagingDelegate
14
14
  import expo.modules.notifications.tokens.interfaces.FirebaseTokenListener
15
+ import org.json.JSONArray
15
16
  import org.json.JSONObject
16
17
  import java.lang.ref.WeakReference
17
18
  import java.util.*
@@ -98,6 +99,14 @@ open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseM
98
99
  protected fun createNotification(remoteMessage: RemoteMessage): Notification {
99
100
  val identifier = getNotificationIdentifier(remoteMessage)
100
101
  val payload = JSONObject(remoteMessage.data as Map<*, *>)
102
+ val vibrationPattern = remoteMessage.notification?.vibrateTimings
103
+ if (vibrationPattern != null) {
104
+ val jsonVibrationTimings = JSONArray()
105
+ vibrationPattern.forEach {
106
+ jsonVibrationTimings.put(it.toInt())
107
+ }
108
+ payload.put("vibrate", jsonVibrationTimings)
109
+ }
101
110
  val content = JSONNotificationContentBuilder(context).setPayload(payload).build()
102
111
  val request = createNotificationRequest(identifier, content, FirebaseNotificationTrigger(remoteMessage))
103
112
  return Notification(request, Date(remoteMessage.sentTime))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-notifications",
3
- "version": "0.28.10",
3
+ "version": "0.28.11",
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": "d8434a8d6017606a9cc92f179c4cfd8ce5aa7f36"
58
+ "gitHead": "c36230e565489a9bbc214704b48a4b266520d157"
59
59
  }