From aaa9436199a1938bc0e5f43d8976121080fc4941 Mon Sep 17 00:00:00 2001 From: Adam Schlesinger Date: Tue, 14 Sep 2021 13:59:15 -0400 Subject: [PATCH] Broke up additional data serialization code --- .../Scripts/OneSignalExampleBehaviour.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/OneSignalExample/Assets/OneSignal/Example/Scripts/OneSignalExampleBehaviour.cs b/OneSignalExample/Assets/OneSignal/Example/Scripts/OneSignalExampleBehaviour.cs index 49241225f..0be6923b2 100644 --- a/OneSignalExample/Assets/OneSignal/Example/Scripts/OneSignalExampleBehaviour.cs +++ b/OneSignalExample/Assets/OneSignal/Example/Scripts/OneSignalExampleBehaviour.cs @@ -213,10 +213,12 @@ private static void HandleNotificationReceived(OSNotification notification) { print("displayType: " + notification.displayType); _logMessage = "Notification received with text: " + message; - print(payload.additionalData != null && Json.Serialize(payload.additionalData) is { } dataString - ? $"[HandleNotificationReceived] message {message}, additionalData: {dataString}" - : "[HandleNotificationReceived] Additional Data == null" - ); + if (payload.additionalData == null) + print("[HandleNotificationReceived] Additional Data == null"); + else if (Json.Serialize(payload.additionalData) is { } dataString) + print($"[HandleNotificationReceived] message {message}, additionalData: {dataString}"); + else + print("[HandleNotificationReceived] Additional Data could not be serialized"); } /// @@ -232,10 +234,12 @@ private static void HandleNotificationOpened(OSNotificationOpenedResult result) print("GameControllerExample:HandleNotificationOpened: " + message); _logMessage = "Notification opened with text: " + message; - print(payload.additionalData != null && Json.Serialize(payload.additionalData) is { } dataString - ? $"[HandleNotificationOpened] message {message}, additionalData: {dataString}" - : "[HandleNotificationOpened] Additional Data == null" - ); + if (payload.additionalData == null) + print("[HandleNotificationOpened] Additional Data == null"); + else if (Json.Serialize(payload.additionalData) is { } dataString) + print($"[HandleNotificationOpened] message {message}, additionalData: {dataString}"); + else + print("[HandleNotificationOpened] Additional Data could not be serialized"); if (actionID != null) { // actionSelected equals the id on the button the user pressed.