友盟推送点击行为处理

来源:互联网 发布:编程真好玩 dk出版社 编辑:程序博客网 时间:2024/06/07 23:06

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
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 大郅谈执教首秀 动态邪郅图22期 动态邪郅图100期图片 王至郅 动态邪郅图9期图片 动态邪郅图2期图片 动态邪郅图618期图片 动态邪郅图47期图片 吉青珂莫与郅鸥现状 雪娇郅美化妆品 郅都 郅颂 郇姓 郇怎么读 郇山隐修会 郇姓氏怎么读 饱饫郇厨 姓郇的男孩儿名字 大明海盗之巅 郇某人 郊狼 乡村小郎中 大唐小郎中 郎中 超级小郎中 俏郎中 小郎中 大宋小郎中 郎中令 三影郎中 香村小郎中 江湖郎中 寄令狐郎中 绝品郎中 妙手小郎中 俏郎中app下载 郎中是什么意思 乡村小郎中免费阅读全文 逍遥小郎中 一弦一柱 黄氏老郎中痔疮膏价格 急惊风遇着慢郎中