node-apn / node-apn

:calling: Apple Push Notification module for Node.js
MIT License
4.37k stars 681 forks source link

How to send an image in notifications #689

Open chandanchhajer opened 3 years ago

chandanchhajer commented 3 years ago

Hi, How we can send an image in notifications for this package. Please share the solution if you have.

johndpope commented 3 years ago

I added this and added all forks - https://gitlab.com/akumria/findforks

searching through the repo / branches (can't do in github) - yields no relevant results.

Screen Shot 2020-10-24 at 1 21 36 pm

UPDATE

https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#apnsfcmoptions

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1

https://stackoverflow.com/questions/37839171/how-to-display-image-in-ios-push-notification/38066583#38066583

seems like mutable-content:1 is the key.

Screen Shot 2020-10-24 at 1 35 52 pm

f1b49caa10748883278429a806611b7f60117103

seems like the rawpayload needs to be overridden / in conjunction with
otherCustomURL:"http://image.com/1.png" though there's no mention of otherCustomURL in this repo https://github.com/node-apn/node-apn/search?q=otherCustomURL


 notification.rawPayload = {
            aps: {
                alert: {
                    title: newTitle,
                    body: newBody
                },
                "mutable-content":1,
                sound: "default",
                badge: 1,
                category: "br.com.inngage.Custom-Notification-Interface.notification",
                otherCustomURL:req.body.sendPushRequest.control_message.image_url ,
                url: req.body.sendPushRequest.control_message.url,
                provider: "inngage",
                id:req.body.sendPushRequest.control_message.notid ,
                inngage_data: ""
            }
        };

https://github.com/johndpope/inn-node-api/blob/master/v4/message/controllers/notifications.js#L849

https://github.com/node-apn/node-apn/blob/8bd4d3c15714409f6a0786d088dfca989843a4f4/doc/notification.markdown

https://devstreaming-cdn.apple.com/videos/wwdc/2016/708tbh8wnspsg01hxwx/708/708_advanced_notifications.pdf?dl=1

Screen Shot 2020-10-24 at 3 34 55 pm