如何自定义百度推送通知? [英] How to customize baidu push notification?

查看:65
本文介绍了如何自定义百度推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了百度推送通知.我面临的问题是我无法自定义其通知UI,也无法从状态栏中清除它,除非我点击它.我可以在他们的演示项目中看到以下代码来自定义UI.但这没有任何区别.请帮助我.

I am using baidu push notification in my app. The issues i am facing are i am not able to customize its notification UI and not able to clear it from status bar unless i tap on that. I could see below code in theirs demo project to customize the UI. But it does not make any difference. please help me.

CustomPushNotificationBuilder cBuilder = new CustomPushNotificationBuilder(
                getApplicationContext(), R.layout.notification_custom_builder,
                R.id.notification_icon, R.id.notification_title,
                R.id.notification_text);
        cBuilder.setNotificationFlags(Notification.FLAG_AUTO_CANCEL);

        cBuilder.setNotificationDefaults(Notification.DEFAULT_SOUND
                | Notification.DEFAULT_VIBRATE);
        cBuilder.setStatusbarIcon(getApplicationContext().getApplicationInfo().icon);
        cBuilder.setNotificationTitle("push");
        cBuilder.setNotificationText("baidu");
        PushManager.setNotificationBuilder(getApplicationContext(), 1, cBuilder);

推荐答案

我得到了这个问题的答案.实际上,我在PushManager.setNotificationBuilder(getApplicationContext(),1,cBuilder)中传递了第二个参数;是通知ID.表示如果您要显示服务器上的自定义UI,则应将此ID与通知一起传递.然后,客户端将使用具有该ID的相应构建器.就我而言,我没有从服务器获取此参数

I got answer for this question. Actually the second parameter i pass in PushManager.setNotificationBuilder(getApplicationContext(), 1, cBuilder); is notification ID. Means if u want to display a custom UI from server this id should be passed with notification. Then client will take corresponding builder with that ID. In my case i was not getting this parameter from server

这篇关于如何自定义百度推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆