question

Jose Jonatas avatar image
Jose Jonatas asked

How to send image in PushNotification? Integration with firebase

Using the firebase api in postman I can send a notification with an image

I would like to do the same thing using playfab's cloudScript

Push Notifications
ys1yz.png (63.9 KiB)
uxn84.png (31.4 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gosen Gao avatar image Gosen Gao commented ·

I will do some tests. Your patience will be appreciated.

0 Likes 0 ·

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

CloudScript classic can send HTTP requests, you can try code like below to send the notification.

handlers.FirebasePush = function (args, context) {
    var headers = {
        "Authorization": "Your Authorization"
    };
    
    var body = {
        "message":{
            "token": "Your token",
            "android":{
                "notification" : {
                    "body" : "This is a Firebase Cloud Messaging Topic Message!",
                    "title" : "FCM Message",
                    "image": "your image"
                }
            }
        }
    }

    var url = "https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send";
    var content = JSON.stringify(body);
    var httpMethod = "post";
    var contentType = "application/json";

    var response = http.request(url, httpMethod, content, contentType, headers);
    return { responseContent: response };
};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.