android - android推送通知的自定义设计

标签 android cordova google-cloud-messaging

如何为文本指定一些自定义 Logo 和样式信息。或者一些自定义操作按钮,就像 Android 中的音乐播放器通知一样。

PS:我已经成功地使用我的应用程序配置了 GCM,并且能够接收来自 GCM 服务器的通知。应用程序是使用 cordova

开发的

最佳答案

您应该阅读更多有关 Android 中的丰富通知的信息。来自官方文档:

To have a notification appear in an expanded view, first create a NotificationCompat.Builder object with the normal view options you want. Next, call Builder.setStyle() with an expanded layout object as its argument.

请看下面的例子:

        NotificationCompat.BigTextStyle textDiv = new NotificationCompat.BigTextStyle();
        textDiv.bigText(bodyMessage); 
        notification = new NotificationCompat.Builder(context)
        .setTicker(bodyMessage)
        .setContentTitle(titleMessage)
        .setSmallIcon(notificationIcon)
        .setStyle(textDiv)
        .setPriority(1)//priority high
        .setVibrate(new long[0])
        .build();

您可以在官方文档中看到更多信息 herehere

关于android - android推送通知的自定义设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34381740/

相关文章:

java - 为什么添加一个空的 for 循环可以修复此代码?

cordova - 在cordova构建后首选项BackupWebStorage重置为默认值

android - 授予无限持久存储权限

java - 是否有用于 GCM 云连接服务器的 Java API

Node.js XMPP 客户端通过 Heroku 实现无法连接

google-cloud-messaging - 应用程序应何时在 GCM 中请求实例 ID 和注册 token ?

android - flutter : change position of text on the appbar

android - 将字符串转换为 double

java - 尽管有 Try/Catch,Android 应用还是崩溃了

cordova - Estimote iBeacons 和 Cordova - 当应用程序被杀死时发送推送通知 iOS