简体   繁体   中英

How to send image using push notification?

How to send push notification with the image using FCM, I have used below things but still just getting only title and text in the notification.

I have used cordova based hybrid application. If anyone has any idea, please let me know.

Sample curl code:

curl https://fcm.googleapis.com/fcm/send -X POST \
--header "Authorization: key=<AUT KEY>" \
--Header "Content-Type: application/json" \
 -d '
 {
   "to": "<to TOKEN>"
   "notification":{
     "title":"New Notification!",
     "body":"Test",
     "color":"#ff0000",
     "icon":"noti_icon",
     "img_url": "https://static.pexels.com/photos/4825/red-love-romantic-flowers.jpg",
     "image"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
    "avatar_url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
    "url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
    "image_url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
    "largeIcon":"http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
   },
   "data" : {
      "img_url": "https://static.pexels.com/photos/4825/red-love-romantic-flowers.jpg",
      "image"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
      "avatar_url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
      "url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
      "image_url"  : "http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
      "message": "Firebase Push Message Using API",
      "largeIcon":"http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
      "main_picture":"http://cernyyachtdesign.com/wp-content/uploads/png-test.png",
    },
   "priority":1
 }'

喜欢这个截图

Thanks.

Finally after 2 days suffer, I got solution to display all types of notification in cordova application.

Plugin Details: https://github.com/phonegap/phonegap-plugin-push

Make sure you have to remove cordova-plugin-firebase if you want to user above plugin, else it will conflict with each other.

For more detail please check above git link which have detail flow of this plugin. I have tested it on android@8.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM