极光推送

来源:互联网 发布:手机怎么查看淘宝积分 编辑:程序博客网 时间:2024/05/17 23:34

极光推送

  • 极光推送需要有

    • 推送设备对象
    • 推送通知内容
    • 推送设置
  • https://github.com/jpush/jpush-api-ruby-client/blob/master/docs/Guides.md#%E6%8E%A8%E9%80%81%E6%B6%88%E6%81%AF


构建 Audience 设备对象

# 链式调用audience = JPush::Push::Audience.new.  set_tag(tag).  set_tag_and(tag_and).  set_tag_not(tag_not).  set_alias(alis).  set_registration_id(registration_ids)

构建 Notification 通知对象内容

notification = JPush::Push::Notification.new.  set_alert(alert).  set_android(    alert: alert,    title: title,    builder_id: builder_id,    extras: extras  ).set_ios(    alert: alert,    sound: sound,    badge: badge,    contentavailable: contentavailable,    mutablecontent: mutablecontent,    category: category,    extras: extras  )

构建 PushPayload 推送设置

options = {  sendno: no,  time_to_live: time,  override_msg_id: msg_id,  apns_production: true,  big_push_duration: duration}# 参数 options 仅接受一个 Hash 对象,而这个 Hash 对象的键也仅支持上面所示的5种。pusher = jpush.pusherpush_payload = JPush::Push::PushPayload.new(  platform: platform,  audience: audience,  notification: notification,  message: message).set_options(options)# 发送推送pusher.push(push_payload)
原创粉丝点击