【问题标题】:Show multiple lines in push notification android Phonegap在推送通知android Phonegap中显示多行
【发布时间】:2023-03-17 17:39:02
【问题描述】:

我遇到了通知问题。我在 PHONEGAP 做我的项目。 我想在 android 的推送通知中显示多行。现在我只收到单行通知。我无法扩展或对该通知做任何事情。我正在使用 phonegap 插件。

com.phonegap.plugins.PushPlugin

请帮助我解决这个问题。 屏幕截图如下。

当前通知

预期通知

【问题讨论】:

标签: android cordova push-notification google-cloud-messaging


【解决方案1】:

这涉及到原生通知(remoteviews)中的自定义布局,所以需要修改你喜欢的插件

Android custom notification layout with RemoteViews

如果是这个插件:https://github.com/phonegap-build/PushPlugin

  1. 使用自定义视图修改 GCMIntentService.java,特别是 NotificationCompat.Builder setContent。此自定义视图可以从 xml 加载或通过代码实例化:How to create a RelativeLayout programmatically with two buttons one on top of the other?

自定义构建器示例:Create custom notification, android

  1. 更改插件的参数或将有效负载消息解析为单独的行

【讨论】:

  • 如何修改?你可以说得更详细点吗 ?我正在使用this 插件。我不知道修改插件。
  • 修改GCMIntentService.java,查看答案
  • 我只想在通知中显示完整的消息。现在它只显示一行内容和标题(参考截图)。如果可能的话,你能帮我用示例代码做同样的事情吗?因为我在android开发方面有点落后。所以我用了phonegap。
  • 如果你使用 .Net 而不是 Java 呢?
【解决方案2】:

路径: \platforms\android\src\com\plugin\gcm

文件名: GCMIntentService.java

String message = extras.getString("message");
        if (message != null) {
            mBuilder.setContentText(message);
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));//add this line

【讨论】:

  • 这个方案对推送通知的样式没有影响。它在 Android 设备上仍然显示为一行。你知道可能是什么问题吗?我是否必须在某处清除缓存或休息插件?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多