thankful-dusk-45985
02/21/2022, 4:43 PMthankful-dusk-45985
02/21/2022, 4:44 PMkind-france-68039
02/22/2022, 11:48 AMnotifications
• Since you wanted to however use firebase functions for this write a onCreate event by giving a path notifications/{id}
• Now in that function use firebase messaging so send notifications, simplest way to do is to sendToTopic and topic id would be uid and in the client application you need to subscribeToTopic uid on login
• Then this should technically work out of the box for android.
• If extending to iOS you would need to add the .p8 file to the firebase console, without this file firebase can’t send notifications.
• Example snippet can be this, note click_action is here for flutter thingy so need not worry about that.
promises.push(
admin.messaging().sendToTopic(uid, {
data: {
storyId: context.params.storyId,
click_action: "FLUTTER_NOTIFICATION_CLICK",
},
notification,
})
);
• The notification above is a json object, which looks like this
{
title: `Title.`,
body: "Message!",
image: "Image",
icon: "icon",
content_available: "true",
};
• Again the content_available is only for iOSthankful-dusk-45985
02/22/2022, 1:25 PMkind-france-68039
02/22/2022, 1:27 PMthankful-dusk-45985
02/22/2022, 2:16 PM