fix expo-notifications patch
This commit is contained in:
@@ -4,10 +4,10 @@ index d233e1f..cc2f856 100644
|
|||||||
+++ b/node_modules/expo-notifications/android/build.gradle
|
+++ b/node_modules/expo-notifications/android/build.gradle
|
||||||
@@ -32,6 +32,7 @@ dependencies {
|
@@ -32,6 +32,7 @@ dependencies {
|
||||||
api 'com.google.firebase:firebase-messaging:22.0.0'
|
api 'com.google.firebase:firebase-messaging:22.0.0'
|
||||||
|
|
||||||
api 'me.leolin:ShortcutBadger:1.1.22@aar'
|
api 'me.leolin:ShortcutBadger:1.1.22@aar'
|
||||||
+ implementation project(':expo-background-notification-handler')
|
+ implementation project(':expo-background-notification-handler')
|
||||||
|
|
||||||
if (project.findProject(':expo-modules-test-core')) {
|
if (project.findProject(':expo-modules-test-core')) {
|
||||||
testImplementation project(':expo-modules-test-core')
|
testImplementation project(':expo-modules-test-core')
|
||||||
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
|
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
|
||||||
@@ -16,14 +16,14 @@ index 0af7fe0..8f2c8d8 100644
|
|||||||
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
|
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/JSONNotificationContentBuilder.java
|
||||||
@@ -14,6 +14,7 @@ import expo.modules.notifications.notifications.enums.NotificationPriority;
|
@@ -14,6 +14,7 @@ import expo.modules.notifications.notifications.enums.NotificationPriority;
|
||||||
import expo.modules.notifications.notifications.model.NotificationContent;
|
import expo.modules.notifications.notifications.model.NotificationContent;
|
||||||
|
|
||||||
public class JSONNotificationContentBuilder extends NotificationContent.Builder {
|
public class JSONNotificationContentBuilder extends NotificationContent.Builder {
|
||||||
+ private static final String CHANNEL_ID_KEY = "channelId";
|
+ private static final String CHANNEL_ID_KEY = "channelId";
|
||||||
private static final String TITLE_KEY = "title";
|
private static final String TITLE_KEY = "title";
|
||||||
private static final String TEXT_KEY = "message";
|
private static final String TEXT_KEY = "message";
|
||||||
private static final String SUBTITLE_KEY = "subtitle";
|
private static final String SUBTITLE_KEY = "subtitle";
|
||||||
@@ -36,6 +37,7 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
|
@@ -36,6 +37,7 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
|
||||||
|
|
||||||
public NotificationContent.Builder setPayload(JSONObject payload) {
|
public NotificationContent.Builder setPayload(JSONObject payload) {
|
||||||
this.setTitle(getTitle(payload))
|
this.setTitle(getTitle(payload))
|
||||||
+ .setChannelId(getChannelId(payload))
|
+ .setChannelId(getChannelId(payload))
|
||||||
@@ -33,7 +33,7 @@ index 0af7fe0..8f2c8d8 100644
|
|||||||
@@ -60,6 +62,14 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
|
@@ -60,6 +62,14 @@ public class JSONNotificationContentBuilder extends NotificationContent.Builder
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ protected String getChannelId(JSONObject payload) {
|
+ protected String getChannelId(JSONObject payload) {
|
||||||
+ try {
|
+ try {
|
||||||
+ return payload.getString(CHANNEL_ID_KEY);
|
+ return payload.getString(CHANNEL_ID_KEY);
|
||||||
@@ -46,21 +46,21 @@ index 0af7fe0..8f2c8d8 100644
|
|||||||
try {
|
try {
|
||||||
return payload.getString(TITLE_KEY);
|
return payload.getString(TITLE_KEY);
|
||||||
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
||||||
index f1fed19..166b34f 100644
|
index f1fed19..80afe9e 100644
|
||||||
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
||||||
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/model/NotificationContent.java
|
||||||
@@ -20,6 +20,7 @@ import expo.modules.notifications.notifications.enums.NotificationPriority;
|
@@ -20,6 +20,7 @@ import expo.modules.notifications.notifications.enums.NotificationPriority;
|
||||||
* should be created using {@link NotificationContent.Builder}.
|
* should be created using {@link NotificationContent.Builder}.
|
||||||
*/
|
*/
|
||||||
public class NotificationContent implements Parcelable, Serializable {
|
public class NotificationContent implements Parcelable, Serializable {
|
||||||
+ private string mChannelId;
|
+ private String mChannelId;
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private String mText;
|
private String mText;
|
||||||
private String mSubtitle;
|
private String mSubtitle;
|
||||||
@@ -50,6 +51,11 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -50,6 +51,11 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public String getChannelId() {
|
+ public String getChannelId() {
|
||||||
+ return mTitle;
|
+ return mTitle;
|
||||||
@@ -71,14 +71,14 @@ index f1fed19..166b34f 100644
|
|||||||
return mTitle;
|
return mTitle;
|
||||||
@@ -121,6 +127,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -121,6 +127,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NotificationContent(Parcel in) {
|
protected NotificationContent(Parcel in) {
|
||||||
+ mChannelId = in.readString();
|
+ mChannelId = in.readString();
|
||||||
mTitle = in.readString();
|
mTitle = in.readString();
|
||||||
mText = in.readString();
|
mText = in.readString();
|
||||||
mSubtitle = in.readString();
|
mSubtitle = in.readString();
|
||||||
@@ -146,6 +153,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -146,6 +153,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
+ dest.writeString(mChannelId);
|
+ dest.writeString(mChannelId);
|
||||||
@@ -87,7 +87,7 @@ index f1fed19..166b34f 100644
|
|||||||
dest.writeString(mSubtitle);
|
dest.writeString(mSubtitle);
|
||||||
@@ -166,6 +174,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -166,6 +174,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
private static final long serialVersionUID = 397666843266836802L;
|
private static final long serialVersionUID = 397666843266836802L;
|
||||||
|
|
||||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
||||||
+ out.writeObject(mChannelId);
|
+ out.writeObject(mChannelId);
|
||||||
out.writeObject(mTitle);
|
out.writeObject(mTitle);
|
||||||
@@ -95,7 +95,7 @@ index f1fed19..166b34f 100644
|
|||||||
out.writeObject(mSubtitle);
|
out.writeObject(mSubtitle);
|
||||||
@@ -190,6 +199,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -190,6 +199,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
+ mChannelId = (String) in.readObject();
|
+ mChannelId = (String) in.readObject();
|
||||||
mTitle = (String) in.readObject();
|
mTitle = (String) in.readObject();
|
||||||
@@ -103,16 +103,16 @@ index f1fed19..166b34f 100644
|
|||||||
mSubtitle = (String) in.readObject();
|
mSubtitle = (String) in.readObject();
|
||||||
@@ -240,6 +250,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -240,6 +250,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
+ private string mChannelId;
|
+ private String mChannelId;
|
||||||
private String mTitle;
|
private String mTitle;
|
||||||
private String mText;
|
private String mText;
|
||||||
private String mSubtitle;
|
private String mSubtitle;
|
||||||
@@ -260,6 +271,11 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -260,6 +271,11 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
useDefaultVibrationPattern();
|
useDefaultVibrationPattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
+ public Builder setChannelId(String channelId) {
|
+ public Builder setChannelId(String channelId) {
|
||||||
+ mChannelId = channelId;
|
+ mChannelId = channelId;
|
||||||
+ return this;
|
+ return this;
|
||||||
@@ -122,7 +122,7 @@ index f1fed19..166b34f 100644
|
|||||||
mTitle = title;
|
mTitle = title;
|
||||||
return this;
|
return this;
|
||||||
@@ -336,6 +352,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
@@ -336,6 +352,7 @@ public class NotificationContent implements Parcelable, Serializable {
|
||||||
|
|
||||||
public NotificationContent build() {
|
public NotificationContent build() {
|
||||||
NotificationContent content = new NotificationContent();
|
NotificationContent content = new NotificationContent();
|
||||||
+ content.mChannelId = mChannelId;
|
+ content.mChannelId = mChannelId;
|
||||||
@@ -134,16 +134,16 @@ index 6bd9928..ee93d70 100644
|
|||||||
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java
|
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java
|
||||||
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java
|
+++ b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/ExpoNotificationBuilder.java
|
||||||
@@ -48,6 +48,10 @@ public class ExpoNotificationBuilder extends ChannelAwareNotificationBuilder {
|
@@ -48,6 +48,10 @@ public class ExpoNotificationBuilder extends ChannelAwareNotificationBuilder {
|
||||||
|
|
||||||
NotificationContent content = getNotificationContent();
|
NotificationContent content = getNotificationContent();
|
||||||
|
|
||||||
+ if (content.getChannelId() != null) {
|
+ if (content.getChannelId() != null) {
|
||||||
+ builder.setChannelId(content.getChannelId());
|
+ builder.setChannelId(content.getChannelId());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
builder.setAutoCancel(content.isAutoDismiss());
|
builder.setAutoCancel(content.isAutoDismiss());
|
||||||
builder.setOngoing(content.isSticky());
|
builder.setOngoing(content.isSticky());
|
||||||
|
|
||||||
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt
|
diff --git a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt b/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt
|
||||||
index 55b3a8d..1b99d5b 100644
|
index 55b3a8d..1b99d5b 100644
|
||||||
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt
|
--- a/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/FirebaseMessagingDelegate.kt
|
||||||
@@ -158,7 +158,7 @@ index 55b3a8d..1b99d5b 100644
|
|||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
-open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseMessagingDelegate {
|
-open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseMessagingDelegate {
|
||||||
+open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseMessagingDelegate, BackgroundNotificationHandlerInterface {
|
+open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseMessagingDelegate, BackgroundNotificationHandlerInterface {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -166,7 +166,7 @@ index 55b3a8d..1b99d5b 100644
|
|||||||
// than by static properties. Fortunately, using weak references we can
|
// than by static properties. Fortunately, using weak references we can
|
||||||
@@ -89,12 +92,21 @@ open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseM
|
@@ -89,12 +92,21 @@ open class FirebaseMessagingDelegate(protected val context: Context) : FirebaseM
|
||||||
fun getBackgroundTasks() = sBackgroundTaskConsumerReferences.values.mapNotNull { it.get() }
|
fun getBackgroundTasks() = sBackgroundTaskConsumerReferences.values.mapNotNull { it.get() }
|
||||||
|
|
||||||
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
override fun onMessageReceived(remoteMessage: RemoteMessage) {
|
||||||
- NotificationsService.receive(context, createNotification(remoteMessage))
|
- NotificationsService.receive(context, createNotification(remoteMessage))
|
||||||
- getBackgroundTasks().forEach {
|
- getBackgroundTasks().forEach {
|
||||||
@@ -181,7 +181,7 @@ index 55b3a8d..1b99d5b 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ override fun showMessage(remoteMessage: RemoteMessage) {
|
+ override fun showMessage(remoteMessage: RemoteMessage) {
|
||||||
+ NotificationsService.receive(context, createNotification(remoteMessage))
|
+ NotificationsService.receive(context, createNotification(remoteMessage))
|
||||||
+ }
|
+ }
|
||||||
|
|||||||
Reference in New Issue
Block a user