Please provide the following:
- SDK Version: 37.0.3
- Platforms(Android/iOS/web/all): Android
I am trying to send push notifications to an Android standalone, managed expo app. We don’t want to eject the app since we love expo’s functionality but need to manage our own notifications instead of using expo’s. When sending notifications using the firebase admin node library, I have gotten the app to handle “recieved” origin notifications. However, “selected” origin ones do not call the handler. The code I am using is based off of this forum post.
I’ve found that every line after the “body: JSON.stringify({ title: messageTitle, body: messageBody }),” line doesn’t seem to do anything. Using the “new” firebase admin api.
const message = {
tokens: deviceTokens,
data: {
// ...messageData,
experienceId: '@ramicaza/FlashPlays', // for expo compatability
title: messageTitle, // for expo compatability
message: messageBody, // for expo compatability
// Following line is for in-app notifications. Shows up as 'data' field on app side :/
body: JSON.stringify({ title: messageTitle, body: messageBody }),
notificationExperienceUrl: "exp://exp.host/@ramicaza/FlashPlays",
notificationId: '-1',
isMultiple: 'false',
remote: 'true',
notification_object: JSON.stringify({
title: messageTitle,
experienceId: '@ramicaza/FlashPlays',
notificationId: -1,
isMultiple: false,
remote: true,
data: { title: messageTitle, body: messageBody }
})
},
// These are for the android system.
android: { //https://firebase.google.com/docs/reference/admin/node/admin.messaging.AndroidNotification
notification: {
title: messageTitle,
body: messageBody,
tag: Math.random().toString(36).substring(2, 15), //workaround for expo GCM and FCM double notif
}
},
};
const res = await androidHandler.messaging().sendMulticast(message);