当用户收到通知时,我想更改/更新标题或正文。在向用户显示通知之前。我的猜测是在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