Android:从使用 MessagingStyle 的通知中获取消息
Android: Get messages from a notification that uses MessagingStyle
我想获取在 Android
中使用 MessagingStyle
的 notification
中显示的消息。
我已经有了获取 notification
实例 (android.app.Notification) 的代码。我看到 NotificationCompat
有一个名为 extractMessagingStyleFromNotification
的函数,但我不能使用 NotificationCompat
因为它不支持 Person
class.
有没有什么方法可以在不使用 NotificationCompat
的情况下检索当前显示在某个通知中的消息?
我知道一种解决方法是将消息列表存储在内存中,并在收到新消息或通知 clicked/dismissed 时更新该列表。但是,我正在开发一个 Cordova
应用程序,并且我有 2 个不同的插件显示通知。要使此解决方法起作用,两个插件应共享此列表,但插件彼此独立,因此这是不可能的。
解决方案是使用 AndroidX 而不是 Android 支持库,因为后者不再更新。对于 AndroidX,我可以使用 NotificationCompat,因为它支持 Person class,所以我可以使用 extractMessagingStyleFromNotification。
我想获取在 Android
中使用 MessagingStyle
的 notification
中显示的消息。
我已经有了获取 notification
实例 (android.app.Notification) 的代码。我看到 NotificationCompat
有一个名为 extractMessagingStyleFromNotification
的函数,但我不能使用 NotificationCompat
因为它不支持 Person
class.
有没有什么方法可以在不使用 NotificationCompat
的情况下检索当前显示在某个通知中的消息?
我知道一种解决方法是将消息列表存储在内存中,并在收到新消息或通知 clicked/dismissed 时更新该列表。但是,我正在开发一个 Cordova
应用程序,并且我有 2 个不同的插件显示通知。要使此解决方法起作用,两个插件应共享此列表,但插件彼此独立,因此这是不可能的。
解决方案是使用 AndroidX 而不是 Android 支持库,因为后者不再更新。对于 AndroidX,我可以使用 NotificationCompat,因为它支持 Person class,所以我可以使用 extractMessagingStyleFromNotification。