【问题标题】:Ionic 2 Google FCM push notification iconIonic 2 Google FCM 推送通知图标
【发布时间】:2017-06-08 20:22:11
【问题描述】:

当我通过 FCM 发送推送通知时,我在设置 Ionic 图标时遇到了一些问题。我的通知如下所示:

var mensaje = {
  "notification":{
    "title": "Some title",
    "body":"Body",
    "sound":"default",
    "click_action":"FCM_PLUGIN_ACTIVITY",
    "icon": "?????"
  },
  "data":{
    "title": "Title",
    "url": "url"
  }
};

在 ionic 应用程序的资源文件夹中,我有一个 logo.png,这是我想用于通知的那个。我应该将什么路由或字符串发送到要显示的图像?

【问题讨论】:

    标签: node.js ionic2 firebase-cloud-messaging cordova-plugin-fcm


    【解决方案1】:

    首先将logo.png 放入drawable 文件夹中,如果您正在为Android 构建,则将此文件夹放入您的platforms/android/res/ 文件夹中。

    完成此操作后,在应用项目中,在初始化通知的代码中放置文件的名称不带扩展名

    如下:

    const pushObj: PushObject = this.push.init({
                            android: {
                                senderID: "your_gcm_id",                                
                                icon: "logo",
                                forceShow: "true"
                            },
                            ios: {
                                alert: "true",
                                badge: "true",
                                sound: "true"
                            }
                        });
    

    现在在服务器端代码中,同样在图标的位置,输入名称logo

    现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-26
      • 2017-01-17
      • 2020-04-21
      • 2019-07-15
      • 2017-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多