标签:友盟推送消息完全自定义处理 友盟推送消息点击跳到指定activity
1,下面的前提是必须申请了友盟且有app key
2,集成友盟SDK 参看官方文档http://dev.umeng.com/push/android/integration#1
3,若开发者需要实现对消息的完全自定义处理,则可以继承 UmengBaseIntentService
, 实现自己的Service来完全控制达到消息的处理。
}
说明:当自定义的参数中有URL时,会被转义,不要在这里面处理,把整个参数传递出去,在需要的地方进行取缔,不然会收不到推送的消息,我的message如下:
message={
"msg_id":"uu56667143874445555800",
"display_type":"notification",
"alias":"",
"random_min":0,
"body":{
"text":"content",
"title":"title",
"ticker":"ticker",
"play_vibrate":"true",
"play_lights":"true",
"play_sound":"true"
},
"extra":{
"otherParams":"
{\"url\":\"http://www.baidu.com\"}",
"displayType":"DISPLAYONWAP"
}
}
自定义的messageItem如下:
package com.pitaya.daokoudai.model.bean.account;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
/**
* 我的消息 bean 包含類型,時間,類容,狀態,消息未读数
*/
public class MessageItem implements Serializable {
private String msmType;
private Long msmDate;
private String msmcontent;
private boolean msmstatus;
private int unreadmsg;
private Long id;
private String displayType;
private String otherParams;
public String getDisplayType() {
return displayType;
}
public void setDisplayType(String displayType) {
this.displayType = displayType;
}
public String getOtherParams() {
return otherParams;
}
public void setOtherParams(String otherParams) {//将参数中的\全部换成“”
String string=otherParams.replaceAll("\\\\","");//是4杠,不是2杠
try {
JSONObject jsonObject=new JSONObject(string);
this.otherParams = jsonObject.optString("url");
} catch (JSONException e) {
e.printStackTrace();
}
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
private String title;
public int getUnreadmsg() {
return unreadmsg;
}
public void setUnreadmsg(int unreadmsg) {
this.unreadmsg = unreadmsg;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMsmType() {
return msmType;
}
public void setMsmType(String msmType) {
this.msmType = msmType;
}
public Long getMsmDate() {
return msmDate;
}
public void setMsmDate(Long msmDate) {
this.msmDate = msmDate;
}
public String getMsmcontent() {
return msmcontent;
}
public void setMsmcontent(String msmcontent) {
this.msmcontent = msmcontent;
}
public boolean getMsmstatus() {
return msmstatus;
}
public void setMsmstatus(boolean msmstatus) {
this.msmstatus = msmstatus;
}
}
2,在AndroidManifest.xml 中声明。
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:友盟推送消息完全自定义处理 友盟推送消息点击跳到指定activity
原文地址:http://blog.csdn.net/banana1006034246/article/details/47295077