expo-notifications 1.0.0-canary-20240912-1059f85 → 1.0.0-canary-20240927-ab8a962

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +24 -4
  2. package/android/build.gradle +10 -7
  3. package/android/src/main/java/expo/modules/notifications/Utils.kt +2 -2
  4. package/android/src/main/java/expo/modules/notifications/notifications/NotificationSerializer.java +6 -10
  5. package/android/src/main/java/expo/modules/notifications/notifications/SoundResolver.java +1 -1
  6. package/android/src/main/java/expo/modules/notifications/notifications/channels/AbstractNotificationsChannelsProvider.java +0 -60
  7. package/android/src/main/java/expo/modules/notifications/notifications/channels/AndroidXNotificationsChannelsProvider.kt +26 -0
  8. package/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationsChannelsProvider.kt +13 -0
  9. package/android/src/main/java/expo/modules/notifications/notifications/channels/managers/AndroidXNotificationsChannelGroupManager.java +1 -2
  10. package/android/src/main/java/expo/modules/notifications/notifications/debug/DebugLogging.kt +2 -4
  11. package/android/src/main/java/expo/modules/notifications/notifications/emitting/NotificationsEmitter.kt +5 -0
  12. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/INotificationContent.kt +38 -0
  13. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationBuilder.kt +34 -0
  14. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationTrigger.java +0 -3
  15. package/android/src/main/java/expo/modules/notifications/notifications/model/Notification.java +7 -7
  16. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java +63 -54
  17. package/android/src/main/java/expo/modules/notifications/notifications/model/NotificationRequest.java +4 -3
  18. package/android/src/main/java/expo/modules/notifications/notifications/model/RemoteNotificationContent.kt +99 -0
  19. package/android/src/main/java/expo/modules/notifications/notifications/presentation/ExpoNotificationPresentationModule.kt +2 -16
  20. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/BaseNotificationBuilder.java +2 -2
  21. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/CategoryAwareNotificationBuilder.java +3 -3
  22. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/DownloadImage.kt +23 -0
  23. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.kt +326 -0
  24. package/android/src/main/java/expo/modules/notifications/service/delegates/ExpoPresentationDelegate.kt +25 -18
  25. package/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt +5 -28
  26. package/build/NotificationScheduler.types.d.ts +25 -11
  27. package/build/NotificationScheduler.types.d.ts.map +1 -1
  28. package/build/NotificationScheduler.types.js.map +1 -1
  29. package/build/Notifications.types.d.ts +68 -37
  30. package/build/Notifications.types.d.ts.map +1 -1
  31. package/build/Notifications.types.js +13 -0
  32. package/build/Notifications.types.js.map +1 -1
  33. package/build/NotificationsEmitter.d.ts +11 -1
  34. package/build/NotificationsEmitter.d.ts.map +1 -1
  35. package/build/NotificationsEmitter.js +30 -2
  36. package/build/NotificationsEmitter.js.map +1 -1
  37. package/build/index.d.ts.map +1 -1
  38. package/build/index.js +9 -0
  39. package/build/index.js.map +1 -1
  40. package/build/scheduleNotificationAsync.d.ts +1 -1
  41. package/build/scheduleNotificationAsync.d.ts.map +1 -1
  42. package/build/scheduleNotificationAsync.js +130 -109
  43. package/build/scheduleNotificationAsync.js.map +1 -1
  44. package/build/useLastNotificationResponse.d.ts.map +1 -1
  45. package/build/useLastNotificationResponse.js +5 -1
  46. package/build/useLastNotificationResponse.js.map +1 -1
  47. package/ios/EXNotifications/Notifications/Emitter/EXNotificationsEmitter.m +7 -0
  48. package/package.json +7 -7
  49. package/plugin/build/withNotificationsAndroid.d.ts +5 -5
  50. package/plugin/build/withNotificationsAndroid.js +18 -16
  51. package/plugin/src/withNotificationsAndroid.ts +18 -18
  52. package/src/NotificationScheduler.types.ts +32 -22
  53. package/src/Notifications.types.ts +73 -41
  54. package/src/NotificationsEmitter.ts +32 -2
  55. package/src/index.ts +13 -0
  56. package/src/scheduleNotificationAsync.ts +166 -151
  57. package/src/useLastNotificationResponse.ts +5 -0
  58. package/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java +0 -203
  59. package/android/src/main/java/expo/modules/notifications/notifications/channels/AndroidXNotificationsChannelsProvider.java +0 -38
  60. package/android/src/main/java/expo/modules/notifications/notifications/channels/NotificationsChannelsProvider.java +0 -13
  61. package/android/src/main/java/expo/modules/notifications/notifications/interfaces/NotificationBuilder.java +0 -35
  62. package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java +0 -292
package/CHANGELOG.md CHANGED
@@ -5,21 +5,41 @@
5
5
  ### 🛠 Breaking changes
6
6
 
7
7
  - Bumped iOS deployment target to 15.1. ([#30840](https://github.com/expo/expo/pull/30840), [#30862](https://github.com/expo/expo/pull/30862) by [@tsapeta](https://github.com/tsapeta))
8
+ - Simplify calendar trigger input types. ([#31598](https://github.com/expo/expo/pull/31598) by [@douglowder](https://github.com/douglowder))
8
9
 
9
10
  ### 🎉 New features
10
11
 
12
+ - Add clearLastNotificationResponseAsync to API. ([#31607](https://github.com/expo/expo/pull/31607) by [@douglowder](https://github.com/douglowder))
13
+
11
14
  ### 🐛 Bug fixes
12
15
 
13
- - [Android] Take `channelId` into account when presenting notifications. ([#31201](https://github.com/expo/expo/pull/31201) by [@vonovak](https://github.com/vonovak))
14
16
  - Add missing `react` and `react-native` peer dependencies for isolated modules. ([#30478](https://github.com/expo/expo/pull/30478) by [@byCedric](https://github.com/byCedric))
15
- - [Android] Eliminate unsupported types when processing notification intents from onCreate/onNewIntent. ([#30750](https://github.com/expo/expo/pull/30750) by [@douglowder](https://github.com/douglowder))
16
- - [Android] Fix content.data in scheduled notifications surfaced to JS. ([#31048](https://github.com/expo/expo/pull/31048) by [@douglowder](https://github.com/douglowder))
17
- - [Android] fix local notifications with null trigger. ([#31157](https://github.com/expo/expo/pull/31157) by [@douglowder](https://github.com/douglowder))
18
17
 
19
18
  ### 💡 Others
20
19
 
20
+ - Warn about limited support in Expo Go ([#31573](https://github.com/expo/expo/pull/31573) by [@vonovak](https://github.com/vonovak))
21
21
  - Keep using the legacy event emitter as the module is not fully migrated to Expo Modules API. ([#28946](https://github.com/expo/expo/pull/28946) by [@tsapeta](https://github.com/tsapeta))
22
22
 
23
+ ## 0.28.17 - 2024-09-17
24
+
25
+ ### 🐛 Bug fixes
26
+
27
+ - [Android] image was missing on android when in foreground ([#31405](https://github.com/expo/expo/pull/31405) by [@vonovak](https://github.com/vonovak))
28
+ - [Android] fix local notifications with null trigger. ([#31157](https://github.com/expo/expo/pull/31157) by [@douglowder](https://github.com/douglowder))
29
+ - [Android] Take `channelId` into account when presenting notifications. ([#31201](https://github.com/expo/expo/pull/31201) by [@vonovak](https://github.com/vonovak))
30
+
31
+ ## 0.28.16 - 2024-08-21
32
+
33
+ ### 🐛 Bug fixes
34
+
35
+ - [Android] Fix content.data in scheduled notifications surfaced to JS. ([#31048](https://github.com/expo/expo/pull/31048) by [@douglowder](https://github.com/douglowder))
36
+
37
+ ## 0.28.15 - 2024-08-05
38
+
39
+ ### 🐛 Bug fixes
40
+
41
+ - [Android] Eliminate unsupported types when processing notification intents from onCreate/onNewIntent. ([#30750](https://github.com/expo/expo/pull/30750) by [@douglowder](https://github.com/douglowder))
42
+
23
43
  ## 0.28.14 - 2024-07-30
24
44
 
25
45
  ### 🐛 Bug fixes
@@ -15,6 +15,7 @@ android {
15
15
  defaultConfig {
16
16
  versionCode 21
17
17
  versionName '0.28.3'
18
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18
19
  }
19
20
 
20
21
  buildFeatures {
@@ -34,17 +35,19 @@ android {
34
35
  }
35
36
 
36
37
  dependencies {
37
- api 'androidx.core:core:1.5.0'
38
- api 'androidx.lifecycle:lifecycle-runtime:2.2.0'
39
- api 'androidx.lifecycle:lifecycle-process:2.2.0'
40
- api 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
38
+ implementation 'androidx.core:core:1.6.0'
39
+ implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'
40
+ implementation 'androidx.lifecycle:lifecycle-process:2.2.0'
41
+ implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
42
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
41
43
 
44
+ // release notes in https://firebase.google.com/support/release-notes/android - cmd + f "Cloud Messaging version"
45
+ implementation 'com.google.firebase:firebase-messaging:24.0.1'
42
46
 
43
- api 'com.google.firebase:firebase-messaging:22.0.0'
44
-
45
- api 'me.leolin:ShortcutBadger:1.1.22@aar'
47
+ implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
46
48
 
47
49
  if (project.findProject(':expo-modules-test-core')) {
48
50
  testImplementation project(':expo-modules-test-core')
51
+ androidTestImplementation project(':expo-modules-test-core')
49
52
  }
50
53
  }
@@ -90,11 +90,11 @@ internal fun isValidJSONString(test: Any?): Boolean {
90
90
  when (test is String) {
91
91
  true -> {
92
92
  try {
93
- JSONObject(test as String)
93
+ JSONObject(test)
94
94
  return true
95
95
  } catch (objectEx: JSONException) {
96
96
  try {
97
- JSONArray(test as String)
97
+ JSONArray(test)
98
98
  return true
99
99
  } catch (arrayEx: JSONException) {
100
100
  return false
@@ -3,7 +3,6 @@ package expo.modules.notifications.notifications;
3
3
  import static expo.modules.notifications.UtilsKt.filteredBundleForJSTypeConverter;
4
4
  import static expo.modules.notifications.UtilsKt.isValidJSONString;
5
5
 
6
- import android.os.Build;
7
6
  import android.os.Bundle;
8
7
 
9
8
  import androidx.annotation.Nullable;
@@ -22,10 +21,10 @@ import java.util.List;
22
21
  import java.util.Map;
23
22
  import java.util.Set;
24
23
 
24
+ import expo.modules.notifications.notifications.interfaces.INotificationContent;
25
25
  import expo.modules.notifications.notifications.interfaces.NotificationTrigger;
26
26
  import expo.modules.notifications.notifications.interfaces.SchedulableNotificationTrigger;
27
27
  import expo.modules.notifications.notifications.model.Notification;
28
- import expo.modules.notifications.notifications.model.NotificationContent;
29
28
  import expo.modules.notifications.notifications.model.NotificationRequest;
30
29
  import expo.modules.notifications.notifications.model.NotificationResponse;
31
30
  import expo.modules.notifications.notifications.model.TextInputNotificationResponse;
@@ -51,7 +50,7 @@ public class NotificationSerializer {
51
50
  public static Bundle toBundle(Notification notification) {
52
51
  Bundle serializedNotification = new Bundle();
53
52
  serializedNotification.putBundle("request", toBundle(notification.getNotificationRequest()));
54
- serializedNotification.putLong("date", notification.getDate().getTime());
53
+ serializedNotification.putLong("date", notification.getOriginDate().getTime());
55
54
  return serializedNotification;
56
55
  }
57
56
 
@@ -99,7 +98,7 @@ public class NotificationSerializer {
99
98
  return result;
100
99
  }
101
100
 
102
- public static Bundle toBundle(NotificationContent content) {
101
+ public static Bundle toBundle(INotificationContent content) {
103
102
  Bundle serializedContent = new Bundle();
104
103
  serializedContent.putString("title", content.getTitle());
105
104
  serializedContent.putString("subtitle", content.getSubtitle());
@@ -113,9 +112,9 @@ public class NotificationSerializer {
113
112
  } else {
114
113
  serializedContent.putString("badge", null);
115
114
  }
116
- if (content.shouldPlayDefaultSound()) {
115
+ if (content.getShouldPlayDefaultSound()) {
117
116
  serializedContent.putString("sound", "default");
118
- } else if (content.getSound() != null) {
117
+ } else if (content.getSoundName() != null) {
119
118
  serializedContent.putString("sound", "custom");
120
119
  } else {
121
120
  serializedContent.putString("sound", null);
@@ -228,10 +227,7 @@ public class NotificationSerializer {
228
227
 
229
228
  @Nullable
230
229
  private static String getChannelId(NotificationTrigger trigger) {
231
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
232
- return trigger.getNotificationChannel();
233
- }
234
- return null;
230
+ return trigger.getNotificationChannel();
235
231
  }
236
232
 
237
233
  @NotNull
@@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
9
9
 
10
10
  /**
11
11
  * A shared logic between ContentBuilders ({@link ArgumentsNotificationContentBuilder}
12
- * and {@link JSONNotificationContentBuilder}) for resolving sounds based on the "sound" property.
12
+ * and {@link RemoteNotificationContent}) for resolving sounds based on the "soundName" property.
13
13
  */
14
14
  public class SoundResolver {
15
15
  private Context mContext;
@@ -2,25 +2,13 @@ package expo.modules.notifications.notifications.channels;
2
2
 
3
3
  import android.content.Context;
4
4
 
5
- import expo.modules.core.ModuleRegistry;
6
5
  import expo.modules.core.interfaces.InternalModule;
7
6
 
8
7
  import java.util.Collections;
9
8
  import java.util.List;
10
9
 
11
- import expo.modules.notifications.notifications.channels.managers.NotificationsChannelGroupManager;
12
- import expo.modules.notifications.notifications.channels.managers.NotificationsChannelManager;
13
- import expo.modules.notifications.notifications.channels.serializers.NotificationsChannelGroupSerializer;
14
- import expo.modules.notifications.notifications.channels.serializers.NotificationsChannelSerializer;
15
-
16
10
  public abstract class AbstractNotificationsChannelsProvider implements NotificationsChannelsProvider, InternalModule {
17
11
  protected final Context mContext;
18
- private NotificationsChannelManager mChannelManager;
19
- private NotificationsChannelGroupManager mChannelGroupManager;
20
- private NotificationsChannelSerializer mChannelSerializer;
21
- private NotificationsChannelGroupSerializer mChannelGroupSerializer;
22
-
23
- private ModuleRegistry mModuleRegistry;
24
12
 
25
13
  public AbstractNotificationsChannelsProvider(Context context) {
26
14
  mContext = context;
@@ -30,52 +18,4 @@ public abstract class AbstractNotificationsChannelsProvider implements Notificat
30
18
  return Collections.singletonList(NotificationsChannelsProvider.class);
31
19
  }
32
20
 
33
- @Override
34
- public void onCreate(ModuleRegistry moduleRegistry) {
35
- mModuleRegistry = moduleRegistry;
36
- }
37
-
38
- public final ModuleRegistry getModuleRegistry() {
39
- return mModuleRegistry;
40
- }
41
-
42
- @Override
43
- public final NotificationsChannelManager getChannelManager() {
44
- if (mChannelManager == null) {
45
- mChannelManager = createChannelManager();
46
- }
47
- return mChannelManager;
48
- }
49
-
50
- @Override
51
- public final NotificationsChannelGroupManager getGroupManager() {
52
- if (mChannelGroupManager == null) {
53
- mChannelGroupManager = createChannelGroupManager();
54
- }
55
- return mChannelGroupManager;
56
- }
57
-
58
- @Override
59
- public final NotificationsChannelSerializer getChannelSerializer() {
60
- if (mChannelSerializer == null) {
61
- mChannelSerializer = createChannelSerializer();
62
- }
63
- return mChannelSerializer;
64
- }
65
-
66
- @Override
67
- public final NotificationsChannelGroupSerializer getGroupSerializer() {
68
- if (mChannelGroupSerializer == null) {
69
- mChannelGroupSerializer = createChannelGroupSerializer();
70
- }
71
- return mChannelGroupSerializer;
72
- }
73
-
74
- protected abstract NotificationsChannelManager createChannelManager();
75
-
76
- protected abstract NotificationsChannelGroupManager createChannelGroupManager();
77
-
78
- protected abstract NotificationsChannelSerializer createChannelSerializer();
79
-
80
- protected abstract NotificationsChannelGroupSerializer createChannelGroupSerializer();
81
21
  }
@@ -0,0 +1,26 @@
1
+ package expo.modules.notifications.notifications.channels
2
+
3
+ import android.content.Context
4
+ import expo.modules.notifications.notifications.channels.managers.AndroidXNotificationsChannelGroupManager
5
+ import expo.modules.notifications.notifications.channels.managers.AndroidXNotificationsChannelManager
6
+ import expo.modules.notifications.notifications.channels.serializers.ExpoNotificationsChannelGroupSerializer
7
+ import expo.modules.notifications.notifications.channels.serializers.ExpoNotificationsChannelSerializer
8
+
9
+ class AndroidXNotificationsChannelsProvider(context: Context) : AbstractNotificationsChannelsProvider(context) {
10
+
11
+ override val groupManager by lazy {
12
+ AndroidXNotificationsChannelGroupManager(context)
13
+ }
14
+
15
+ override val channelManager by lazy {
16
+ AndroidXNotificationsChannelManager(context, groupManager)
17
+ }
18
+
19
+ override val channelSerializer by lazy {
20
+ ExpoNotificationsChannelSerializer()
21
+ }
22
+
23
+ override val groupSerializer by lazy {
24
+ ExpoNotificationsChannelGroupSerializer(channelSerializer)
25
+ }
26
+ }
@@ -0,0 +1,13 @@
1
+ package expo.modules.notifications.notifications.channels
2
+
3
+ import expo.modules.notifications.notifications.channels.managers.NotificationsChannelGroupManager
4
+ import expo.modules.notifications.notifications.channels.managers.NotificationsChannelManager
5
+ import expo.modules.notifications.notifications.channels.serializers.NotificationsChannelGroupSerializer
6
+ import expo.modules.notifications.notifications.channels.serializers.NotificationsChannelSerializer
7
+
8
+ interface NotificationsChannelsProvider {
9
+ val channelManager: NotificationsChannelManager
10
+ val groupManager: NotificationsChannelGroupManager
11
+ val channelSerializer: NotificationsChannelSerializer
12
+ val groupSerializer: NotificationsChannelGroupSerializer
13
+ }
@@ -54,10 +54,9 @@ public class AndroidXNotificationsChannelGroupManager implements NotificationsCh
54
54
  // Processing options
55
55
  @RequiresApi(api = Build.VERSION_CODES.O)
56
56
  protected void configureGroupWithOptions(Object maybeGroup, ReadableArguments groupOptions) {
57
- if (!(maybeGroup instanceof NotificationChannelGroup)) {
57
+ if (!(maybeGroup instanceof NotificationChannelGroup group)) {
58
58
  return;
59
59
  }
60
- NotificationChannelGroup group = (NotificationChannelGroup) maybeGroup;
61
60
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
62
61
  if (groupOptions.containsKey(DESCRIPTION_KEY)) {
63
62
  group.setDescription(groupOptions.getString(DESCRIPTION_KEY));
@@ -61,7 +61,6 @@ object DebugLogging {
61
61
  Log.i("expo-notifications", logMessage)
62
62
  }
63
63
 
64
- @RequiresApi(Build.VERSION_CODES.O)
65
64
  fun logNotification(caller: String, notification: Notification) {
66
65
  if (!BuildConfig.DEBUG) {
67
66
  // Do not log for release/production builds
@@ -73,12 +72,11 @@ object DebugLogging {
73
72
  notification.notificationRequest.content.title: ${notification.notificationRequest.content.title}
74
73
  notification.notificationRequest.content.subtitle: ${notification.notificationRequest.content.subtitle}
75
74
  notification.notificationRequest.content.text: ${notification.notificationRequest.content.text}
76
- notification.notificationRequest.content.sound: ${notification.notificationRequest.content.sound}
75
+ notification.notificationRequest.content.sound: ${notification.notificationRequest.content.soundName}
77
76
  notification.notificationRequest.content.channelID: ${notification.notificationRequest.trigger.notificationChannel}
78
77
  notification.notificationRequest.content.body: ${notification.notificationRequest.content.body}
79
78
  notification.notificationRequest.content.color: ${notification.notificationRequest.content.color}
80
- notification.notificationRequest.content.vibrationPattern: ${notification.notificationRequest.content.vibrationPattern.contentToString()}
81
- notification.notificationRequest.trigger.notificationChannel: ${notification.notificationRequest.trigger.notificationChannel}
79
+ notification.notificationRequest.content.vibrationPattern: ${notification.notificationRequest.content.vibrationPattern?.contentToString()}
82
80
  notification.notificationRequest.identifier: ${notification.notificationRequest.identifier}
83
81
  """.trimIndent()
84
82
 
@@ -41,6 +41,11 @@ open class NotificationsEmitter : Module(), NotificationListener {
41
41
  AsyncFunction<Bundle?>("getLastNotificationResponseAsync") {
42
42
  lastNotificationResponseBundle
43
43
  }
44
+
45
+ AsyncFunction("clearLastNotificationResponseAsync") {
46
+ lastNotificationResponseBundle = null
47
+ null
48
+ }
44
49
  }
45
50
 
46
51
  /**
@@ -0,0 +1,38 @@
1
+ package expo.modules.notifications.notifications.interfaces
2
+
3
+ import android.content.Context
4
+ import android.graphics.Bitmap
5
+ import android.os.Parcelable
6
+ import expo.modules.notifications.notifications.enums.NotificationPriority
7
+ import org.json.JSONObject
8
+
9
+ /**
10
+ * This interface is implemented by classes representing notification content.
11
+ * I.e. local notifications [NotificationContent] and remote notifications [RemoteNotificationContent].
12
+ *
13
+ * The reason the two classes exist is that one is persisted locally in SharedPreferences, and the other is not.
14
+ * The first is therefore a bit "fragile" and harder to refactor, while the second is easier to change.
15
+ * This interface exists to provide a common API for both classes.
16
+ * */
17
+ interface INotificationContent : Parcelable {
18
+ val title: String?
19
+ val text: String?
20
+ val subtitle: String?
21
+ val badgeCount: Number?
22
+ val shouldPlayDefaultSound: Boolean
23
+
24
+ // soundName is better off as a string (was an Uri) because in RemoteNotification we can obtain the sound name
25
+ // in local notification we store the uri and derive the sound name from it
26
+ val soundName: String?
27
+ val shouldUseDefaultVibrationPattern: Boolean
28
+ val vibrationPattern: LongArray?
29
+ val body: JSONObject?
30
+ val priority: NotificationPriority
31
+ val color: Number?
32
+ val isAutoDismiss: Boolean
33
+ val categoryId: String?
34
+ val isSticky: Boolean
35
+
36
+ fun containsImage(): Boolean
37
+ suspend fun getImage(context: Context): Bitmap?
38
+ }
@@ -0,0 +1,34 @@
1
+ package expo.modules.notifications.notifications.interfaces
2
+
3
+ import expo.modules.notifications.notifications.model.Notification
4
+ import expo.modules.notifications.notifications.model.NotificationBehavior
5
+
6
+ /**
7
+ * An object capable of building a [Notification] based
8
+ * on a [NotificationContent] spec.
9
+ */
10
+ interface NotificationBuilder {
11
+ /**
12
+ * Pass in a [Notification] based on which the Android notification should be based.
13
+ *
14
+ * @param notification [Notification] on which the notification should be based.
15
+ * @return The same instance of [NotificationBuilder] updated with the notification.
16
+ */
17
+ fun setNotification(notification: Notification?): NotificationBuilder?
18
+
19
+ /**
20
+ * Pass in a [NotificationBehavior] if you want to override the behavior
21
+ * of the notification, i.e. whether it should show a heads-up alert, set badge, etc.
22
+ *
23
+ * @param behavior [NotificationBehavior] to which the presentation effect should conform.
24
+ * @return The same instance of [NotificationBuilder] updated with the remote message.
25
+ */
26
+ fun setAllowedBehavior(behavior: NotificationBehavior?): NotificationBuilder?
27
+
28
+ /**
29
+ * Builds the Android notification based on passed in data.
30
+ *
31
+ * @return Built notification.
32
+ */
33
+ suspend fun build(): android.app.Notification
34
+ }
@@ -1,10 +1,8 @@
1
1
  package expo.modules.notifications.notifications.interfaces;
2
2
 
3
- import android.os.Build;
4
3
  import android.os.Parcelable;
5
4
 
6
5
  import androidx.annotation.Nullable;
7
- import androidx.annotation.RequiresApi;
8
6
 
9
7
  /**
10
8
  * An interface specifying source of the notification, to be implemented
@@ -12,7 +10,6 @@ import androidx.annotation.RequiresApi;
12
10
  */
13
11
  public interface NotificationTrigger extends Parcelable {
14
12
  @Nullable
15
- @RequiresApi(api = Build.VERSION_CODES.O)
16
13
  default String getNotificationChannel() {
17
14
  return null;
18
15
  }
@@ -6,11 +6,11 @@ import android.os.Parcelable;
6
6
  import java.util.Date;
7
7
 
8
8
  /**
9
- * A class representing a single notification received at a particular moment ({@link #mDate}).
9
+ * A class representing a single notification. Origin date ({@link #mOriginDate}) is time when it was sent (remote) or when it was posted (local).
10
10
  */
11
11
  public class Notification implements Parcelable {
12
12
  private NotificationRequest mRequest;
13
- private Date mDate;
13
+ private Date mOriginDate;
14
14
 
15
15
  public Notification(NotificationRequest request) {
16
16
  this(request, new Date());
@@ -18,16 +18,16 @@ public class Notification implements Parcelable {
18
18
 
19
19
  public Notification(NotificationRequest request, Date date) {
20
20
  mRequest = request;
21
- mDate = date;
21
+ mOriginDate = date;
22
22
  }
23
23
 
24
24
  protected Notification(Parcel in) {
25
25
  mRequest = in.readParcelable(getClass().getClassLoader());
26
- mDate = new Date(in.readLong());
26
+ mOriginDate = new Date(in.readLong());
27
27
  }
28
28
 
29
- public Date getDate() {
30
- return mDate;
29
+ public Date getOriginDate() {
30
+ return mOriginDate;
31
31
  }
32
32
 
33
33
  public NotificationRequest getNotificationRequest() {
@@ -54,6 +54,6 @@ public class Notification implements Parcelable {
54
54
  @Override
55
55
  public void writeToParcel(Parcel dest, int flags) {
56
56
  dest.writeParcelable(mRequest, 0);
57
- dest.writeLong(mDate.getTime());
57
+ dest.writeLong(mOriginDate.getTime());
58
58
  }
59
59
  }