起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4507|回复: 4

[处理中] 极光推送,app如何获取自定义字段和标题内容!

[复制链接]

9

主题

31

帖子

83

积分

初级会员

Rank: 2

积分
83
QQ
发表于 2016-9-27 12:03:13 | 显示全部楼层 |阅读模式
20金币
我用的是模式4,想实现点击推送信息,跳转回APP进入指定界面,就需要传参数,我研究过外卖案例,没什么头绪,以下是我试行的代码,请大神解决,谢谢!

  1. <script type="text/javascript" src="/cordova.js"></script>
  2. <script type="text/javascript">
  3. $(function() {

  4.         var JPushInstance = function() {
  5.                 if (window.plugins && window.plugins.jPushPlugin) {
  6.                         document.addEventListener("deviceready", this.onDeviceReady.bind(this), false);
  7.                         document.addEventListener("jpush.openNotification", this.onOpenNotification.bind(this), false);
  8.                         document.addEventListener("jpush.receiveNotification", this.onReceiveNotification.bind(this), false);
  9.                         document.addEventListener("jpush.receiveMessage", this.onReceiveMessage.bind(this), false);
  10.                 }
  11.         };
  12.         
  13.         //hcr 解决第一次获取失败的问题
  14.         JPushInstance.prototype.getRegistrationID = function(){
  15.                  var dtd = $.Deferred();
  16.                  if (this.registrationID){
  17.                          dtd.resolve(this.registrationID);
  18.                  }else{
  19.                          if (window.plugins && window.plugins.jPushPlugin){
  20.                                  window.plugins.jPushPlugin.getRegistrationID(function(registrationID) {
  21.                                          self.registrationID = registrationID;
  22.                                          if (self.registrationID){
  23.                                                  dtd.resolve(self.registrationID);         
  24.                                          }else{
  25.                                                  dtd.reject();
  26.                                          }
  27.                                  });
  28.                          }else{
  29.                                  dtd.reject();
  30.                          }
  31.                  }
  32.                  return dtd.promise();
  33.         };
  34.         

  35.         JPushInstance.prototype.onDeviceReady = function() {
  36.                 var self = this;
  37.                 window.plugins.jPushPlugin.init();
  38.                 window.plugins.jPushPlugin.getRegistrationID(function(registrationID) {
  39.                         self.registrationID = registrationID;
  40.                 });
  41.                 if (device.platform == "Android") {
  42.                         window.plugins.jPushPlugin.setDebugMode(false);
  43.                         window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
  44.                 } else {
  45.                         window.plugins.jPushPlugin.setDebugMode(false);
  46.                         window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
  47.                 }
  48.         };

  49.         JPushInstance.prototype.onOpenNotification = function(event) {
  50.                 var alertContent;
  51.                 if (device.platform == "Android") {
  52.                         alertContent = window.plugins.jPushPlugin.openNotification.alert;
  53.                 } else {
  54.                         alertContent = event.aps.alert;
  55.                 }
  56.                 window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
  57.                 alert(alertContent);
  58.         };

  59.         JPushInstance.prototype.onReceiveNotification = function(event) {
  60.                 var alertContent;
  61.         if(device.platform == "Android"){
  62.                 alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
  63.         }else{
  64.                 alertContent   = event.aps.alert;
  65.         }
  66.         window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
  67.                 alert(alertContent);
  68.         };

  69.         JPushInstance.prototype.onReceiveMessage = function() {
  70.                 var message;
  71.         if(device.platform == "Android"){
  72.                         message = window.plugins.jPushPlugin.receiveMessage.message;
  73.         }else{
  74.               message   = event.content;
  75.         }
  76.         window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
  77.                 alert(message);
  78.         };

  79.         new JPushInstance();
  80. });

  81. </script>
复制代码



75

主题

486

帖子

862

积分

高级会员

Rank: 4

积分
862
QQ
发表于 2016-9-27 14:25:53 | 显示全部楼层
我做过极光推送 你说的参数 是指 id 之类的吗?  就是点击推送的信息,后处理。
http://bbs.justep.com/thread-49855-1-1.html
点评回复

使用道具 举报

75

主题

486

帖子

862

积分

高级会员

Rank: 4

积分
862
QQ
发表于 2016-9-27 14:26:26 | 显示全部楼层
可以加我qq 咨询
http://bbs.justep.com/thread-49855-1-1.html
点评回复

使用道具 举报

9

主题

31

帖子

83

积分

初级会员

Rank: 2

积分
83
QQ
 楼主| 发表于 2016-9-27 15:07:30 | 显示全部楼层
有没有用【模式4】做过的大侠?赶紧帮下忙,谢谢!
点评回复

使用道具 举报

9

主题

31

帖子

83

积分

初级会员

Rank: 2

积分
83
QQ
 楼主| 发表于 2016-9-27 15:38:32 | 显示全部楼层
高手在哪里?求帮忙?
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-4-27 08:46 , Processed in 0.057108 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表