在某些情况下,我将需要发送一些消息并在后台执行某些操作,我在OneSignal的文档中发现了这个示例,该示例显示了如何设置,但是我看不到如何获得该消息。它已发送!
public class NotificationExtenderBare extends NotificationExtenderService {
@Override
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
// Sets the background notification color to Green on Android 5.0+ devices.
return builder.setColor(new BigInteger("FF00FF00", 16).intValue());
}
};
OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings);
// Read properties from result.
// Return true to stop the notification from displaying.
return true;
答案 0 :(得分:0)
感谢您的提问。我将更新文档以使其更加清晰。
您可以使用receivedResult.payload
这是OSNotificationReceivedResult
public class OSNotificationReceivedResult {
public boolean restoring;
public boolean isAppInFocus;
public OSNotificationPayload payload;
}
编辑:使用示例代码将docs更新为更加清晰