友盟推送点击行为处理

http://blog.csdn.net/dreamj1991/article/details/68065531

注:友盟后台推送,后台必须设置返回数据自定义,返回点击行为不可以为默认打开app,再者就是custom数据设置,要不然
      手机端接收不到。

 // 点击"通知"的后续行为,默认为打开app。
        "after_open": "xx" // 必填 值可以为:
                                   "go_app": 打开应用
                                   "go_url": 跳转到URL
                                   "go_activity": 打开特定的activity
                                   "go_custom": 用户自定义内容。
        "url": "xx",       // 可选 当"after_open"为"go_url"时,必填。
                                   通知栏点击后跳转的URL,要求以http或者https开头  
        "activity":"xx",   // 可选 当"after_open"为"go_activity"时,必填。
                                   通知栏点击后打开的Activity
        "custom":"xx"/{}   // 可选 display_type=message, 或者
                                   display_type=notification且
                                   "after_open"为"go_custom"时,
                                   该字段必填。用户自定义内容, 可以为字符串或者JSON格式。








/**
         * 该Handler是在BroadcastReceiver中被调用,故
         * 如果需启动Activity,需添加Intent.FLAG_ACTIVITY_NEW_TASK
         * 参考集成文档的1.6.2
         * [url=http://dev.umeng.com/push/android/integration#1_6_2]http://dev.umeng.com/push/android/integration#1_6_2[/url]
         * */
        UmengNotificationClickHandler notificationClickHandler = new UmengNotificationClickHandler(){
            //点击通知的自定义行为
            @Override
            public void dealWithCustomAction(Context context, UMessage msg) {
                if(msg!=null){
                JSONObject obj = new JSONObject(msg.extra);
                Push push = new Push();
                push.setResource(obj.optString("resource"));
                push.setType(obj.optString("type"));
                push.setApplication_id(obj.optString("application_id"));
                push.setMember_id(obj.optString("member_id"));
                    switch(push.getResource()){
                        case Push.GUARANTEE:
                            if(push.getType().equals("保荐")){
                                if(Utility.isGuarantor) {
                                    openWebViewWithToken(URLs.HTML_SPONSOR_LIST);
                                } else {
                                    openWebViewWithToken(URLs.HTML_SPONSOR_CENTER);
                                }
                            }else {
                                openWebViewWithToken(URLs.HTML_GUARANTEE_LIST);
                            }
                        break;
                        case Push.APPLICATION:
                            openWebView(URLs.HTML_LOAN_DETAIL, null, null, push.getApplication_id());
                        break;
                        case Push.SYSTEM:
                            startActivity(Main.class,0, Intent.FLAG_ACTIVITY_NEW_TASK);
                        break;
                        case Push.FRIENDS:
                            startActivity(MessageCenterActivity.class,1, Intent.FLAG_ACTIVITY_NEW_TASK);
                            break;


                    }


                }else{
                    startActivity(Main.class,0,Intent.FLAG_ACTIVITY_NEW_TASK);
                }




            }
        };
        mPushAgent.setNotificationClickHandler(notificationClickHandler);
接收数据实体类:
public class Push {


    /**
     * resource : guarantee
     * id : 306
     * application_id : 285
     * member_id : 508
     * type : 保荐
     */


    final  public static int GUARANTEE = 1;
    final public static int APPLICATION  = 2;
    final  public static int SYSTEM  = 3;
    final  public static int FRIENDS  = 4;


    private int resource;
    private String id;
    private String application_id;
    private String member_id;
    private String type;


    public int getResource() {
        return resource;
    }


    public void setResource(String resource) {
        if(resource.equals("application")){
            this.resource = APPLICATION;
        }
        if(resource.equals("system")){
            this.resource = SYSTEM;
        }
        if(resource.equals("guarantee")){
            this.resource = GUARANTEE;
        }
        if(resource.equals("friend ")){
            this.resource = FRIENDS;
        }
    }


    public String getId() {
        return id;
    }


    public void setId(String id) {
        this.id = id;
    }


    public String getApplication_id() {
        return application_id;
    }


    public void setApplication_id(String application_id) {
        this.application_id = application_id;
    }


    public String getMember_id() {
        return member_id;
    }


    public void setMember_id(String member_id) {
        this.member_id = member_id;
    }


    public String getType() {
        return type;
    }


    public void setType(String type) {
        this.type = type;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值