OneSignal 通知 - 在接收和显示之前更新通知标题 (android)
OneSignal notification - update notification title on receive and before displaying it (android)
当用户收到通知时我想change/update标题或body。在向用户显示通知之前。我的猜测是在 NotificationExtenderService.onNotificationProcessing
或 OneSignal.NotificationReceivedHandler
中实现这个
但是不知道 API 文档怎么也没有帮助。
已解决。您可以在 onNotificationProcessing 事件中更改提醒值。
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
builder.setContentText....
builder.setContentTitle...
}
}
}
您不能简单地通过构建器方法 setContentText() 进行覆盖。
请检查 OneSignal 存储库中问题的答案。
https://github.com/OneSignal/OneSignal-Android-SDK/issues/717
当用户收到通知时我想change/update标题或body。在向用户显示通知之前。我的猜测是在 NotificationExtenderService.onNotificationProcessing
或 OneSignal.NotificationReceivedHandler
中实现这个
但是不知道 API 文档怎么也没有帮助。
已解决。您可以在 onNotificationProcessing 事件中更改提醒值。
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
builder.setContentText....
builder.setContentTitle...
}
}
}
您不能简单地通过构建器方法 setContentText() 进行覆盖。 请检查 OneSignal 存储库中问题的答案。
https://github.com/OneSignal/OneSignal-Android-SDK/issues/717