繁体   English   中英

如何使用推送通知发送图像?

[英]How to send image using push notification?

如何使用FCM向图像发送推送通知,我已经使用了下面的内容,但仍然只是在通知中获取标题和文本。

我使用过基于cordova的混合应用程序。 如果有人有任何想法,请告诉我。

样本卷曲代码:

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
 }'

喜欢这个截图

谢谢。

最后,经过2天的苦难,我得到了解决方案,以显示所有类型的通知在cordova应用程序中。

插件详细信息: https//github.com/phonegap/phonegap-plugin-push

如果你想使用上面的插件,请确保你必须删除cordova-plugin-firebase,否则它将相互冲突。

有关更多详细信息,请查看上面的git链接,其中包含此插件的详细信息流程。 我在android@8.0.0上测试过它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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