简体   繁体   English

如何自定义百度推送通知?

[英]How to customize baidu push notification?

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. 我面临的问题是我无法自定义其通知UI,也无法从状态栏中清除它,除非我点击了它。 I could see below code in theirs demo project to customize the UI. 我可以在他们的演示项目中看到以下代码来自定义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);

I got answer for this question. 我得到了这个问题的答案。 Actually the second parameter i pass in PushManager.setNotificationBuilder(getApplicationContext(), 1, cBuilder); 实际上,我在PushManager.setNotificationBuilder(getApplicationContext(),1,cBuilder)中传递了第二个参数; is notification ID. 是通知ID。 Means if u want to display a custom UI from server this id should be passed with notification. 意味着如果您要从服务器显示自定义UI,则应将此ID连同通知一起传递。 Then client will take corresponding builder with that ID. 然后客户端将使用具有该ID的相应构建器。 In my case i was not getting this parameter from server 就我而言,我没有从服务器获取此参数

you can pass setNotificationTitle("notification_title"); 您可以传递setNotificationTitle(“ notification_title”); and setNotificationText("notification_content"); 和setNotificationText(“ notification_content”); this two parameter is fixed from baidu push notification server 这两个参数是从百度推送通知服务器修复的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM