个推推送消息通知大图、大文本

通知栏消息支持富文本与大图消息,使消息更富个性化。具体字段详见个推多厂商参数介绍

个推推送消息通知大图、大文本

一、需求背景

1.1 背景描述

通知栏消息支持富文本与大图消息,使消息更富个性化。具体字段详见个推多厂商参数介绍

1.2 名称解释

名词解释
富文本通知栏消息展示长文本样式
大图通知栏消息展示大图样式

1.3 各渠道支持情况

渠道长文本大图
个推支持支持
华为支持不支持
荣耀支持不支持
小米支持支持
oppo支持支持
魅族不支持不支持
vivo不支持不支持
apns不支持支持

二、功能实现

开发者可通过调用 个推服务端 api 或者登陆 个推开发者中心 从页面下发消息。

2.1 个推开发者中心设置

1、长文本设置新手指引

①登录 个推开发者中心,打开【个推消息推送】,点击【创建消息】后在【Android配置】中选择【展开式通知】。

大图1

②选择【大文本】样式并将补充的内容填写至文本框即可。

③根据页面说明填写好其他配置信息,查看推送预览,确认无误后,点击【确定】,正式发送推送。

大图2

长文本样式示意图

2、大图设置新手指引

①登录个推开发者中心,打开【个推消息推送】,点击【创建消息】后在【Android配置】版块中点击【展开式通知】 ,选择【大图样式】展示样式。

②设计一张430*230的亮眼大图,主题鲜明,亮点突出。

③上传大图,大小不超过200KB,支持JPEG、PNG格式。

大图3

④根据页面说明填写好其他配置信息,查看推送预览,确认无误后,点击【确定】,正式发送推送。

大图4

2.1 服务端 api 设置

个推

{
    "push_message":{
        "notification":{
            "title":"请填写你的通知标题",
            "body":"请填写你的通知内容",
            "big_text":"请填写你的通知长文本",
            "logo":"logo.png",
            "logo_url":"http://xxxx/a.png",
            "channel_id":"请填写你的channel_id",
            "channel_name":"请填写你的channel_name",
            "channel_level":3,
            "click_type":"intent",
            "intent":"intent://com.getui.push/detail?#Intent;scheme=gtpushscheme;launchFlags=0x4000000;package=com.getui.demo;component=com.getui.demo/com.getui.demo.DemoActivity;S.payload=payloadStr;end"
        }
    }
}

华为

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "HW": {
          "/message/android/notification/style": 1,
          "/message/android/notification/big_title": "big_title",
          "/message/android/notification/big_body": "big_body"
        }
      }
    }
  }
}

荣耀

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "HO": {
          "/android/notification/style": 1,
          "/android/notification/bigTitle": "bigTitle",
          "/android/notification/bigBody": "bigBody"
        }
      }
    }
  }
}

小米

notification_style_type = 1表示多字版。填1时,文本内容为body内的值

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "XM": {
          "/extra.notification_style_type": 1
        }
      }
    }
  }
}

oppo

style = 2 长文本样式(ColorOS版本>5.0可用,通知栏第一条消息可展示全部内容,非第一条消息只展示一行内容)

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "OP": {
          "/style": 2
        }
      }
    }
  }
}

2.2 服务端大图

个推

big_image = 大图的URL地址,通知消息+大图样式, 与big_text二选一,两个都填写时报错,URL长度 ≤ 1024

{
    "push_message":{
        "notification":{
            "title":"请填写你的通知标题",
            "body":"请填写你的通知内容",
            "big_image":"请填写你的通知大图URL",
            "logo":"logo.png",
            "logo_url":"http://xxxx/a.png",
            "channel_id":"请填写你的channel_id",
            "channel_name":"请填写你的channel_name",
            "channel_level":3,
            "click_type":"intent",
            "intent":"intent:#Intent;action=;end"
        }
    }
}

小米

/extra.notification_style_type填2时,填写,表示大图地址(上传到小米返回的url) 图片要求:固定876x324px,小于1M,PNG/JPG/JPEG格式。

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "XM": {
          "/extra.notification_style_type": 2,
          "/extra.notification_bigPic_uri":"http://url.big.pic/xxx.png"
        }
      }
    }
  }
}

oppo

big_picture_id :先调用OPPO接口,上传图片,填写接口返回的图标id,style为3时必填 图片要求:尺寸876*324px,文件大小1M以内,格式为PNG/JPG/JPEG。

通知大图不支持单推,单推请求会返回无权限错误

{
  "android": {
    "ups": {
      "notification": {
        // ...其他push_channel参数略
      },
      "options": {
        "OP": {
          "/style": 3,
          "/big_picture_id": "接口返回的图标id"
        }
      }
    }
  }
}

iOS(apns)

离线apns通知大图消息,长按通知栏消息不要点进去会跳出大图

{
    "ios":{
        "type":"notify",
        "payload":"自定义消息",
        "aps":{
            "alert":{
                "title":"通知标题",
                "body":"通知内容"
            },
            "content-available":0,
            "sound":"com.gexin.ios.silence",
            "category":"ACTIONABLE"
        },
        "auto_badge":"+1",
        "multimedia": [{
            "url": "https://xxx,并且带有后缀格式(.jpg、mp3、mp4)的多媒体图片",
            "type": 1,
            "only_wifi": false
        }]
    }
}

编辑:yimen,如若转载,请注明出处:https://www.yimenapp.com/kb-yimen/15475/

部分内容来自网络投稿,如有侵权联系立删

(0)
上一篇 2022年12月21日 下午5:32
下一篇 2022年12月21日 下午5:35

相关推荐