diff --git a/OneSignalSDK.DotNet.Android.Core.Binding/OneSignalSDK.DotNet.Android.Core.Binding.csproj b/OneSignalSDK.DotNet.Android.Core.Binding/OneSignalSDK.DotNet.Android.Core.Binding.csproj
index 751d03dc..d391e253 100644
--- a/OneSignalSDK.DotNet.Android.Core.Binding/OneSignalSDK.DotNet.Android.Core.Binding.csproj
+++ b/OneSignalSDK.DotNet.Android.Core.Binding/OneSignalSDK.DotNet.Android.Core.Binding.csproj
@@ -15,6 +15,7 @@
>28.0.3
class-parse
+ $(NoWarn);CS0618;BG8A00;BG8102;BG8401;BG8403;BG8502;BG8503;BG8605;BG8606;BG8700;BG8701;BG8800;BG8801;BG8C00;BG8C01
true
@@ -37,12 +38,6 @@
false
false
-
-
-
-
-
-
diff --git a/OneSignalSDK.DotNet.Android.InAppMessages.Binding/OneSignalSDK.DotNet.Android.InAppMessages.Binding.csproj b/OneSignalSDK.DotNet.Android.InAppMessages.Binding/OneSignalSDK.DotNet.Android.InAppMessages.Binding.csproj
index eccb20d5..7eb56102 100644
--- a/OneSignalSDK.DotNet.Android.InAppMessages.Binding/OneSignalSDK.DotNet.Android.InAppMessages.Binding.csproj
+++ b/OneSignalSDK.DotNet.Android.InAppMessages.Binding/OneSignalSDK.DotNet.Android.InAppMessages.Binding.csproj
@@ -15,6 +15,7 @@
>28.0.3
class-parse
+ $(NoWarn);BG8A04;BG8605;BG8606
true
@@ -37,12 +38,6 @@
false
false
-
-
-
-
-
-
diff --git a/OneSignalSDK.DotNet.Android.Location.Binding/OneSignalSDK.DotNet.Android.Location.Binding.csproj b/OneSignalSDK.DotNet.Android.Location.Binding/OneSignalSDK.DotNet.Android.Location.Binding.csproj
index 0120a275..ab0810e1 100644
--- a/OneSignalSDK.DotNet.Android.Location.Binding/OneSignalSDK.DotNet.Android.Location.Binding.csproj
+++ b/OneSignalSDK.DotNet.Android.Location.Binding/OneSignalSDK.DotNet.Android.Location.Binding.csproj
@@ -15,6 +15,7 @@
>28.0.3
class-parse
+ $(NoWarn);BG8A04;BG8605;BG8606
true
@@ -37,12 +38,6 @@
false
false
-
-
-
-
-
-
diff --git a/OneSignalSDK.DotNet.Android.Notifications.Binding/OneSignalSDK.DotNet.Android.Notifications.Binding.csproj b/OneSignalSDK.DotNet.Android.Notifications.Binding/OneSignalSDK.DotNet.Android.Notifications.Binding.csproj
index a468d23e..8b8a6842 100644
--- a/OneSignalSDK.DotNet.Android.Notifications.Binding/OneSignalSDK.DotNet.Android.Notifications.Binding.csproj
+++ b/OneSignalSDK.DotNet.Android.Notifications.Binding/OneSignalSDK.DotNet.Android.Notifications.Binding.csproj
@@ -15,6 +15,7 @@
>28.0.3
class-parse
+ $(NoWarn);BG8A04;BG8401;BG8403;BG8605;BG8606
true
@@ -37,12 +38,6 @@
false
false
-
-
-
-
-
-
diff --git a/OneSignalSDK.DotNet.Android/AndroidLiveActivitiesManager.cs b/OneSignalSDK.DotNet.Android/AndroidLiveActivitiesManager.cs
index 0366fdad..82640636 100644
--- a/OneSignalSDK.DotNet.Android/AndroidLiveActivitiesManager.cs
+++ b/OneSignalSDK.DotNet.Android/AndroidLiveActivitiesManager.cs
@@ -31,7 +31,7 @@ public void SetPushToStartToken(string activityType, string token)
Console.WriteLine("OneSignal: SetPushToStartToken is available on iOS only");
}
- public void SetupDefault(LiveActivitySetupOptions options = null)
+ public void SetupDefault(LiveActivitySetupOptions? options = null)
{
Console.WriteLine("OneSignal: SetupDefault is available on iOS only");
}
diff --git a/OneSignalSDK.DotNet.Android/AndroidNotificationsManager.cs b/OneSignalSDK.DotNet.Android/AndroidNotificationsManager.cs
index 6c74b3c3..992aa39e 100644
--- a/OneSignalSDK.DotNet.Android/AndroidNotificationsManager.cs
+++ b/OneSignalSDK.DotNet.Android/AndroidNotificationsManager.cs
@@ -190,38 +190,38 @@ as IDictionary
public AndroidDisplayableNotification(
Com.OneSignal.Android.Notifications.IDisplayableNotification displayableNotification,
- string title,
- string body,
- string sound,
- string launchUrl,
+ string? title,
+ string? body,
+ string? sound,
+ string? launchUrl,
IList actionButtons,
IDictionary additionalData,
- string notificationId,
- IList groupedNotifications = null,
- BackgroundImageLayout backgroundImageLayout = null,
- string templateId = null,
- string templateName = null,
- string groupKey = null,
- string groupMessage = null,
- string ledColor = null,
+ string? notificationId,
+ IList? groupedNotifications = null,
+ BackgroundImageLayout? backgroundImageLayout = null,
+ string? templateId = null,
+ string? templateName = null,
+ string? groupKey = null,
+ string? groupMessage = null,
+ string? ledColor = null,
int? priority = null,
- string smallIcon = null,
- string largeIcon = null,
- string bigPicture = null,
- string collapseId = null,
- string fromProjectNumber = null,
- string smallIconAccentColor = null,
+ string? smallIcon = null,
+ string? largeIcon = null,
+ string? bigPicture = null,
+ string? collapseId = null,
+ string? fromProjectNumber = null,
+ string? smallIconAccentColor = null,
int? lockScreenVisibility = null,
int? androidNotificationId = null,
int? badge = null,
int? badgeIncrement = null,
- string category = null,
- string threadId = null,
- string subtitle = null,
+ string? category = null,
+ string? threadId = null,
+ string? subtitle = null,
float? relevanceScore = null,
bool? mutableContent = null,
bool? contentAvailable = null,
- string interruptionLevel = null
+ string? interruptionLevel = null
)
: base(
title,
diff --git a/OneSignalSDK.DotNet.Android/AndroidOneSignal.cs b/OneSignalSDK.DotNet.Android/AndroidOneSignal.cs
index 78d46486..1fadaf80 100644
--- a/OneSignalSDK.DotNet.Android/AndroidOneSignal.cs
+++ b/OneSignalSDK.DotNet.Android/AndroidOneSignal.cs
@@ -15,14 +15,13 @@ namespace OneSignalSDK.DotNet.Android;
public class AndroidOneSignal : IOneSignal
{
- /** These static references are not used, but we need to reference at least one class
- * in the binding projects that are otherwised not referenced. If we did *not*, then
- * the binding DLLs will not be included in the output bin directory.
- */
-
- private static Com.OneSignal.Android.InAppMessages.IInAppMessagesManager InAppMessagesBuildConfig;
- private static Com.OneSignal.Android.Notifications.INotificationsManager NotificationsBuildConfig;
- private static Com.OneSignal.Android.Location.ILocationManager LocationBuildConfig;
+ /** Retain binding assembly references so optional module DLLs are copied to output. */
+ private static readonly Type[] BindingRetentionTypes =
+ {
+ typeof(Com.OneSignal.Android.InAppMessages.IInAppMessagesManager),
+ typeof(Com.OneSignal.Android.Notifications.INotificationsManager),
+ typeof(Com.OneSignal.Android.Location.ILocationManager),
+ };
public IUserManager User { get; } = new AndroidUserManager();
diff --git a/OneSignalSDK.DotNet.Android/AndroidUserManager.cs b/OneSignalSDK.DotNet.Android/AndroidUserManager.cs
index 93e27649..9f33bee2 100644
--- a/OneSignalSDK.DotNet.Android/AndroidUserManager.cs
+++ b/OneSignalSDK.DotNet.Android/AndroidUserManager.cs
@@ -25,25 +25,25 @@ public void Initialize()
((AndroidPushSubscription)PushSubscription).Initialize();
}
- public string OneSignalId
+ public string? OneSignalId
{
get
{
- string id = OneSignalNative.User.OnesignalId;
+ string? id = OneSignalNative.User.OnesignalId;
return string.IsNullOrEmpty(id) ? null : id;
}
}
- public string ExternalId
+ public string? ExternalId
{
get
{
- string id = OneSignalNative.User.ExternalId;
+ string? id = OneSignalNative.User.ExternalId;
return string.IsNullOrEmpty(id) ? null : id;
}
}
- public event EventHandler Changed;
+ public event EventHandler? Changed;
public void AddAlias(string label, string id) => OneSignalNative.User.AddAlias(label, id);
@@ -71,20 +71,20 @@ public void RemoveAliases(params string[] labels) =>
public void RemoveTags(params string[] keys) => OneSignalNative.User.RemoveTags(keys);
- public IDictionary GetTags() => OneSignalNative.User.Tags;
+ public IDictionary? GetTags() => OneSignalNative.User.Tags;
public void TrackEvent(string name, IDictionary? properties = null)
{
- OneSignalNative.User.TrackEvent(name, ToNativeConversion.DictToJavaMap(properties));
+ OneSignalNative.User.TrackEvent(name, ToNativeConversion.DictToJavaMap(properties)!);
}
private sealed class InternalUserState : IUserState
{
- public string OneSignalId { get; }
+ public string? OneSignalId { get; }
- public string ExternalId { get; }
+ public string? ExternalId { get; }
- public InternalUserState(string onesignalId, string externalId)
+ public InternalUserState(string? onesignalId, string? externalId)
{
OneSignalId = onesignalId;
ExternalId = externalId;
@@ -116,11 +116,11 @@ public void OnUserStateChange(Com.OneSignal.Android.User.State.UserChangedState
public class AndroidPushSubscription : IPushSubscription
{
- public string Token => OneSignalNative.User.PushSubscription.Token;
+ public string? Token => OneSignalNative.User.PushSubscription.Token;
public bool OptedIn => OneSignalNative.User.PushSubscription.OptedIn;
- public string Id => OneSignalNative.User.PushSubscription.Id;
+ public string? Id => OneSignalNative.User.PushSubscription.Id;
public event EventHandler? Changed;
@@ -144,13 +144,13 @@ public void OptOut()
private sealed class InternalPushSubscriptionState : IPushSubscriptionState
{
- public string Id { get; }
+ public string? Id { get; }
- public string Token { get; }
+ public string? Token { get; }
public bool OptedIn { get; }
- public InternalPushSubscriptionState(string token, bool optedIn, string id)
+ public InternalPushSubscriptionState(string? token, bool optedIn, string? id)
{
Token = token;
OptedIn = optedIn;
diff --git a/OneSignalSDK.DotNet.Android/OneSignalSDK.DotNet.Android.csproj b/OneSignalSDK.DotNet.Android/OneSignalSDK.DotNet.Android.csproj
index a461b69e..78605e20 100644
--- a/OneSignalSDK.DotNet.Android/OneSignalSDK.DotNet.Android.csproj
+++ b/OneSignalSDK.DotNet.Android/OneSignalSDK.DotNet.Android.csproj
@@ -8,6 +8,7 @@
Library
21
enable
+ enable
OneSignalSDK.DotNet.Android
OneSignalSDK.DotNet.Android
Resources
diff --git a/OneSignalSDK.DotNet.Android/Utilities/ToNativeConversion.cs b/OneSignalSDK.DotNet.Android/Utilities/ToNativeConversion.cs
index fad341f5..9e99e06d 100644
--- a/OneSignalSDK.DotNet.Android/Utilities/ToNativeConversion.cs
+++ b/OneSignalSDK.DotNet.Android/Utilities/ToNativeConversion.cs
@@ -31,6 +31,7 @@ public static Com.OneSignal.Android.Debug.LogLevel ToLogLevel(LogLevel logLevel)
}
}
+#pragma warning disable CA1422 // Java.Lang boxed types remain required for primitive interop on minSdk 21.
public static Java.Lang.Object? ToJavaObject(object? value)
{
if (value == null)
@@ -91,6 +92,7 @@ public static Com.OneSignal.Android.Debug.LogLevel ToLogLevel(LogLevel logLevel)
return null;
}
+#pragma warning restore CA1422
public static IDictionary? DictToJavaMap(
IDictionary? dict
diff --git a/OneSignalSDK.DotNet.Core/IOneSignal.cs b/OneSignalSDK.DotNet.Core/IOneSignal.cs
index 5929f8fb..3e9a265f 100644
--- a/OneSignalSDK.DotNet.Core/IOneSignal.cs
+++ b/OneSignalSDK.DotNet.Core/IOneSignal.cs
@@ -102,7 +102,7 @@ public interface IOneSignal
/// login operation.Required when identity verification has been enabled. See
/// Identity Verification | OneSignal
///
- void Login(String externalId, String jwtBearerToken = null);
+ void Login(String externalId, String? jwtBearerToken = null);
///
/// Logout the user previously logged in via . The
diff --git a/OneSignalSDK.DotNet.Core/InAppMessages/InAppMessageClickResult.cs b/OneSignalSDK.DotNet.Core/InAppMessages/InAppMessageClickResult.cs
index 721cae73..12b38c72 100644
--- a/OneSignalSDK.DotNet.Core/InAppMessages/InAppMessageClickResult.cs
+++ b/OneSignalSDK.DotNet.Core/InAppMessages/InAppMessageClickResult.cs
@@ -12,12 +12,12 @@ public class InAppMessageClickResult
///
/// An optional action id defined for the action element
///
- public string ActionId { get; }
+ public string? ActionId { get; }
///
/// An optional URL that opens when the action takes place
///
- public string Url { get; }
+ public string? Url { get; }
///
/// Optional where the url will be launched
@@ -30,8 +30,8 @@ public class InAppMessageClickResult
public bool ClosingMessage { get; }
public InAppMessageClickResult(
- string actionId,
- string url,
+ string? actionId,
+ string? url,
InAppMessageActionUrlType urlTarget,
bool closingMessage
)
diff --git a/OneSignalSDK.DotNet.Core/Internal/Utilities/Json.cs b/OneSignalSDK.DotNet.Core/Internal/Utilities/Json.cs
index 59d548d2..5f52ef66 100644
--- a/OneSignalSDK.DotNet.Core/Internal/Utilities/Json.cs
+++ b/OneSignalSDK.DotNet.Core/Internal/Utilities/Json.cs
@@ -13,7 +13,7 @@ public static class Json
///
/// A JSON string.
/// An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false
- public static object Deserialize(string json)
+ public static object? Deserialize(string? json)
{
// save the string for debug information
if (json == null)
@@ -22,6 +22,7 @@ public static object Deserialize(string json)
return Parser.Parse(json);
}
+#nullable disable
sealed class Parser : IDisposable
{
const string WORD_BREAK = "{}[],:\"";
@@ -363,6 +364,8 @@ TOKEN NextToken
}
}
+#nullable restore
+
///
/// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string
///
@@ -373,6 +376,7 @@ public static string Serialize(object obj)
return Serializer.Serialize(obj);
}
+#nullable disable
sealed class Serializer
{
StringBuilder builder;
@@ -393,9 +397,9 @@ public static string Serialize(object obj)
void SerializeValue(object value)
{
+ string asStr;
IList asList;
IDictionary asDict;
- string asStr;
if (value == null)
{
@@ -552,5 +556,6 @@ value is int
}
}
}
+#nullable restore
}
}
diff --git a/OneSignalSDK.DotNet.Core/Internal/Utilities/WrapperSDK.cs b/OneSignalSDK.DotNet.Core/Internal/Utilities/WrapperSDK.cs
index 4c808f0d..3d69a145 100644
--- a/OneSignalSDK.DotNet.Core/Internal/Utilities/WrapperSDK.cs
+++ b/OneSignalSDK.DotNet.Core/Internal/Utilities/WrapperSDK.cs
@@ -8,7 +8,7 @@ public static class WrapperSDK
{
public static string Type = "dotnet";
- public static string Version
+ public static string? Version
{
get
{
diff --git a/OneSignalSDK.DotNet.Core/LiveActivities/ILiveActivities.cs b/OneSignalSDK.DotNet.Core/LiveActivities/ILiveActivities.cs
index 427b79c2..94e30e45 100644
--- a/OneSignalSDK.DotNet.Core/LiveActivities/ILiveActivities.cs
+++ b/OneSignalSDK.DotNet.Core/LiveActivities/ILiveActivities.cs
@@ -35,7 +35,7 @@ public interface ILiveActivitiesManager
/// Only applies to iOS.
///
/// An optional structure to provide for more granular setup options.
- void SetupDefault(LiveActivitySetupOptions options = null);
+ void SetupDefault(LiveActivitySetupOptions? options = null);
///
/// Start a new LiveActivity that is modelled by the default`DefaultLiveActivityAttributes`
diff --git a/OneSignalSDK.DotNet.Core/Notifications/DisplayableNotification.cs b/OneSignalSDK.DotNet.Core/Notifications/DisplayableNotification.cs
index f0b49579..e70d5fdf 100644
--- a/OneSignalSDK.DotNet.Core/Notifications/DisplayableNotification.cs
+++ b/OneSignalSDK.DotNet.Core/Notifications/DisplayableNotification.cs
@@ -9,38 +9,38 @@ namespace OneSignalSDK.DotNet.Core.Notifications
public abstract class DisplayableNotification : Notification
{
public DisplayableNotification(
- string title,
- string body,
- string sound,
- string launchUrl,
+ string? title,
+ string? body,
+ string? sound,
+ string? launchUrl,
IList actionButtons,
IDictionary additionalData,
- string notificationId,
- IList groupedNotifications = null,
- BackgroundImageLayout backgroundImageLayout = null,
- string templateId = null,
- string templateName = null,
- string groupKey = null,
- string groupMessage = null,
- string ledColor = null,
+ string? notificationId,
+ IList? groupedNotifications = null,
+ BackgroundImageLayout? backgroundImageLayout = null,
+ string? templateId = null,
+ string? templateName = null,
+ string? groupKey = null,
+ string? groupMessage = null,
+ string? ledColor = null,
int? priority = null,
- string smallIcon = null,
- string largeIcon = null,
- string bigPicture = null,
- string collapseId = null,
- string fromProjectNumber = null,
- string smallIconAccentColor = null,
+ string? smallIcon = null,
+ string? largeIcon = null,
+ string? bigPicture = null,
+ string? collapseId = null,
+ string? fromProjectNumber = null,
+ string? smallIconAccentColor = null,
int? lockScreenVisibility = null,
int? androidNotificationId = null,
int? badge = null,
int? badgeIncrement = null,
- string category = null,
- string threadId = null,
- string subtitle = null,
+ string? category = null,
+ string? threadId = null,
+ string? subtitle = null,
float? relevanceScore = null,
bool? mutableContent = null,
bool? contentAvailable = null,
- string interruptionLevel = null
+ string? interruptionLevel = null
)
: base(
title,
diff --git a/OneSignalSDK.DotNet.Core/Notifications/Notification.cs b/OneSignalSDK.DotNet.Core/Notifications/Notification.cs
index 95df1d29..05d454fa 100644
--- a/OneSignalSDK.DotNet.Core/Notifications/Notification.cs
+++ b/OneSignalSDK.DotNet.Core/Notifications/Notification.cs
@@ -11,22 +11,22 @@ public class Notification
///
/// The title displayed to the user.
///
- public string Title { get; }
+ public string? Title { get; }
///
/// The body displayed to the user.
///
- public string Body { get; }
+ public string? Body { get; }
///
/// The sound information specified when creating the notification.
///
- public string Sound { get; }
+ public string? Sound { get; }
///
/// The launch URL information specified when creating the notification.
///
- public string LaunchUrl { get; }
+ public string? LaunchUrl { get; }
///
/// The action buttons specified when creating the notification.
@@ -42,45 +42,45 @@ public class Notification
///
/// The OneSignal notification id.
///
- public string NotificationId { get; }
+ public string? NotificationId { get; }
///
/// When non-null this is a summary notification, and this contains the list of notifications this summarizes.
///
- public IList GroupedNotifications { get; }
+ public IList? GroupedNotifications { get; }
///
/// The background image layout information specified when creating the notification.
///
- public BackgroundImageLayout BackgroundImageLayout { get; }
+ public BackgroundImageLayout? BackgroundImageLayout { get; }
///
/// The id of the OneSignal tempalte that created this notification. If no template was used,
/// this will be null.
///
- public string TemplateId { get; }
+ public string? TemplateId { get; }
///
/// The name of the OneSignal template that created this notification. If no template was
/// used, this will be null.
///
- public string TemplateName { get; }
+ public string? TemplateName { get; }
#region Android
///
/// (Android Only) The group key information specified when creating the notification.
///
- public string GroupKey { get; }
+ public string? GroupKey { get; }
///
/// (Android Only) The group message information specified when creating the notification.
///
- public string GroupMessage { get; }
+ public string? GroupMessage { get; }
///
/// (Android Only) The LED color information specified when creating the notification.
///
- public string LedColor { get; }
+ public string? LedColor { get; }
///
/// (Android Only) The priority information specified when creating the notification.
@@ -90,32 +90,32 @@ public class Notification
///
/// (Android Only) The small icon information specified when creating the notification.
///
- public string SmallIcon { get; }
+ public string? SmallIcon { get; }
///
/// (Android Only) The large icon information specified when creating the notification.
///
- public string LargeIcon { get; }
+ public string? LargeIcon { get; }
///
/// (Android Only) The big picture information specified when creating the notification.
///
- public string BigPicture { get; }
+ public string? BigPicture { get; }
///
/// (Android Only) The collapse ID specified when creating the notification.
///
- public string CollapseId { get; }
+ public string? CollapseId { get; }
///
/// (Android Only) The from project information specified when creating the notification.
///
- public string FromProjectNumber { get; }
+ public string? FromProjectNumber { get; }
///
/// (Android Only) The accent color of the small icon specified when creating the notification.
///
- public string SmallIconAccentColor { get; }
+ public string? SmallIconAccentColor { get; }
///
/// (Android Only) The lock screen visibility information specified when creating the notification.
@@ -142,17 +142,17 @@ public class Notification
///
/// (iOS Only) Show associated actions and buttons for the category.
///
- public string Category { get; }
+ public string? Category { get; }
///
/// The ID of the thread (group) this notification is within.
///
- public string ThreadId { get; }
+ public string? ThreadId { get; }
///
/// (iOS Only) The subtitle of the notification.
///
- public string Subtitle { get; }
+ public string? Subtitle { get; }
///
/// (iOS Only) The order the notification is shown for users that have chosen to receive your notifications as part
@@ -173,42 +173,42 @@ public class Notification
///
/// (iOS Only) When and how the notification is displayed.
///
- public string InterruptionLevel { get; }
+ public string? InterruptionLevel { get; }
#endregion iOS
public Notification(
- string title,
- string body,
- string sound,
- string launchUrl,
+ string? title,
+ string? body,
+ string? sound,
+ string? launchUrl,
IList actionButtons,
IDictionary additionalData,
- string notificationId,
- IList groupedNotifications = null,
- BackgroundImageLayout backgroundImageLayout = null,
- string templateId = null,
- string templateName = null,
- string groupKey = null,
- string groupMessage = null,
- string ledColor = null,
+ string? notificationId,
+ IList? groupedNotifications = null,
+ BackgroundImageLayout? backgroundImageLayout = null,
+ string? templateId = null,
+ string? templateName = null,
+ string? groupKey = null,
+ string? groupMessage = null,
+ string? ledColor = null,
Nullable priority = null,
- string smallIcon = null,
- string largeIcon = null,
- string bigPicture = null,
- string collapseId = null,
- string fromProjectNumber = null,
- string smallIconAccentColor = null,
+ string? smallIcon = null,
+ string? largeIcon = null,
+ string? bigPicture = null,
+ string? collapseId = null,
+ string? fromProjectNumber = null,
+ string? smallIconAccentColor = null,
Nullable lockScreenVisibility = null,
Nullable androidNotificationId = null,
Nullable badge = null,
Nullable badgeIncrement = null,
- string category = null,
- string threadId = null,
- string subtitle = null,
+ string? category = null,
+ string? threadId = null,
+ string? subtitle = null,
Nullable relevanceScore = null,
Nullable mutableContent = null,
Nullable contentAvailable = null,
- string interruptionLevel = null
+ string? interruptionLevel = null
)
{
Title = title;
@@ -254,19 +254,19 @@ public class ActionButton
///
/// The ID of the action button specified when creating the notification.
///
- public string Id { get; }
+ public string? Id { get; }
///
/// The text displayed on the action button.
///
- public string Text { get; }
+ public string? Text { get; }
///
/// The icon displayed on the action button.
///
- public string Icon { get; }
+ public string? Icon { get; }
- public ActionButton(string id, string text, string icon)
+ public ActionButton(string? id, string? text, string? icon)
{
Id = id;
Text = text;
diff --git a/OneSignalSDK.DotNet.Core/Notifications/NotificationClickResult.cs b/OneSignalSDK.DotNet.Core/Notifications/NotificationClickResult.cs
index ef768dbc..fde1393d 100644
--- a/OneSignalSDK.DotNet.Core/Notifications/NotificationClickResult.cs
+++ b/OneSignalSDK.DotNet.Core/Notifications/NotificationClickResult.cs
@@ -7,11 +7,11 @@ namespace OneSignalSDK.DotNet.Core.Notifications
///
public class NotificationClickResult
{
- public string ActionId { get; }
+ public string? ActionId { get; }
- public string Url { get; }
+ public string? Url { get; }
- public NotificationClickResult(string actionId, string url)
+ public NotificationClickResult(string? actionId, string? url)
{
ActionId = actionId;
Url = url;
diff --git a/OneSignalSDK.DotNet.Core/User/IUserManager.cs b/OneSignalSDK.DotNet.Core/User/IUserManager.cs
index 3edd5512..132debd9 100644
--- a/OneSignalSDK.DotNet.Core/User/IUserManager.cs
+++ b/OneSignalSDK.DotNet.Core/User/IUserManager.cs
@@ -38,7 +38,7 @@ public interface IUserManager
///
/// The UUID generated by OneSignal to represent a user, null if this is currently unavailable.
///
- string OneSignalId { get; }
+ string? OneSignalId { get; }
///
/// The External ID is OneSignal's default and recommended alias label. This should be the main
@@ -46,7 +46,7 @@ public interface IUserManager
///
/// This is null if the External ID has not been set.
///
- string ExternalId { get; }
+ string? ExternalId { get; }
///
/// When onesignalId or externalId has changed
@@ -148,7 +148,7 @@ public interface IUserManager
///
/// Get the dictionary of data tags for the current user.
///
- IDictionary GetTags();
+ IDictionary? GetTags();
///
/// Track a custom event with the provided name and optional properties.
diff --git a/OneSignalSDK.DotNet.Core/User/IUserState.cs b/OneSignalSDK.DotNet.Core/User/IUserState.cs
index 8d8852b3..41045b39 100644
--- a/OneSignalSDK.DotNet.Core/User/IUserState.cs
+++ b/OneSignalSDK.DotNet.Core/User/IUserState.cs
@@ -5,17 +5,17 @@ namespace OneSignalSDK.DotNet.Core.User
public interface IUserState
{
///
- /// The unique identifier for your OneSignal account. This will be an empty string until the
+ /// The unique identifier for your OneSignal account. This will be null until the
/// user has been successfully logged in on the backend and assigned an ID.
/// Use [Changed] to be notified when the [OneSignalId] has been successfully assigned.
///
- string OneSignalId { get; }
+ string? OneSignalId { get; }
///
/// The external identifier that you use to identify users. Use [Changed] to be notified
- /// when the [ExternalId] has been successfully assigned. This will be an empty string if no
+ /// when the [ExternalId] has been successfully assigned. This will be null if no
/// external identifier has been assigned to the associated [OneSignalId].
///
- string ExternalId { get; }
+ string? ExternalId { get; }
}
}
diff --git a/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscription.cs b/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscription.cs
index 6f52e452..46290def 100644
--- a/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscription.cs
+++ b/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscription.cs
@@ -13,17 +13,17 @@ public interface IPushSubscription
event EventHandler Changed;
///
- /// The unique identifier for this subscription. This will be an empty string
+ /// The unique identifier for this subscription. This will be null
/// until the subscription has been successfully created on the backend and
/// assigned an ID.
///
- string Id { get; }
+ string? Id { get; }
///
- /// The token which identifies the device/app that notifications are to be sent. May
- /// be an empty string, indicating the push token has not yet been retrieved.
+ /// The token which identifies the device/app that notifications are to be sent. May be
+ /// null, indicating the push token has not yet been retrieved.
///
- string Token { get; }
+ string? Token { get; }
///
/// Whether the user of this subscription is opted-in to received notifications. When true,
diff --git a/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscriptionState.cs b/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscriptionState.cs
index c3a801b6..1d1bcd3e 100644
--- a/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscriptionState.cs
+++ b/OneSignalSDK.DotNet.Core/User/Subscriptions/IPushSubscriptionState.cs
@@ -8,17 +8,17 @@ namespace OneSignalSDK.DotNet.Core.User.Subscriptions
public interface IPushSubscriptionState
{
///
- /// The unique identifier for this subscription. This will be an empty string
+ /// The unique identifier for this subscription. This will be null
/// until the subscription has been successfully created on the backend and
/// assigned an ID.
///
- string Id { get; }
+ string? Id { get; }
///
- /// The token which identifies the device/app that notifications are to be sent. May
- /// be an empty string, indicating the push token has not yet been retrieved.
+ /// The token which identifies the device/app that notifications are to be sent. May be
+ /// null, indicating the push token has not yet been retrieved.
///
- string Token { get; }
+ string? Token { get; }
///
/// Whether the user of this subscription is opted-in to received notifications. When true,
diff --git a/OneSignalSDK.DotNet.iOS.Binding/OneSignalSDK.DotNet.iOS.Binding.csproj b/OneSignalSDK.DotNet.iOS.Binding/OneSignalSDK.DotNet.iOS.Binding.csproj
index 436c57d8..b0a34785 100644
--- a/OneSignalSDK.DotNet.iOS.Binding/OneSignalSDK.DotNet.iOS.Binding.csproj
+++ b/OneSignalSDK.DotNet.iOS.Binding/OneSignalSDK.DotNet.iOS.Binding.csproj
@@ -12,6 +12,7 @@
Resources
OneSignalSDK.DotNet.iOS.Binding
true
+ $(NoWarn);CS0114
true
diff --git a/OneSignalSDK.DotNet.iOS/OneSignalSDK.DotNet.iOS.csproj b/OneSignalSDK.DotNet.iOS/OneSignalSDK.DotNet.iOS.csproj
index 8c5fbac7..0c20e980 100644
--- a/OneSignalSDK.DotNet.iOS/OneSignalSDK.DotNet.iOS.csproj
+++ b/OneSignalSDK.DotNet.iOS/OneSignalSDK.DotNet.iOS.csproj
@@ -8,6 +8,7 @@
true
Resources
12.2
+ enable
OneSignalSDK.DotNet.iOS
OneSignalSDK.DotNet.iOS
Resources
diff --git a/OneSignalSDK.DotNet.iOS/Utilities/FromNativeConversion.cs b/OneSignalSDK.DotNet.iOS/Utilities/FromNativeConversion.cs
index f6e3b385..97f668e4 100644
--- a/OneSignalSDK.DotNet.iOS/Utilities/FromNativeConversion.cs
+++ b/OneSignalSDK.DotNet.iOS/Utilities/FromNativeConversion.cs
@@ -1,7 +1,5 @@
using System.Collections.Generic;
-using System.Text.Json;
using Foundation;
-using HomeKit;
using OneSignalSDK.DotNet.Core;
using OneSignalSDK.DotNet.Core.InAppMessages;
using OneSignalSDK.DotNet.Core.Internal.Utilities;
@@ -15,37 +13,31 @@ namespace OneSignalSDK.DotNet.iOS.Utilities;
///
public static class FromNativeConversion
{
- public static Dictionary NSObjectToPureDict(NSObject nSObject)
+ public static Dictionary? NSObjectToPureDict(NSObject nSObject)
{
- if (nSObject == null)
+ var jsonString = SerializeToJsonString(nSObject);
+ if (jsonString == null)
return null;
- NSError error;
- NSData jsonData = NSJsonSerialization.Serialize(nSObject, 0, out error);
- NSString jsonNSString = NSString.FromData(jsonData, NSStringEncoding.UTF8);
- string jsonString = jsonNSString.ToString();
- return Json.Deserialize(jsonString) as Dictionary;
+
+ return DeserializeStringDictionary(jsonString);
}
- public static Dictionary NSDictToPureDict(NSDictionary nsDict)
+ public static Dictionary? NSDictToPureDict(NSDictionary nsDict)
{
- if (nsDict == null)
+ var jsonString = SerializeToJsonString(nsDict);
+ if (jsonString == null)
return null;
- NSError error;
- NSData jsonData = NSJsonSerialization.Serialize(nsDict, 0, out error);
- NSString jsonNSString = NSString.FromData(jsonData, NSStringEncoding.UTF8);
- string jsonString = jsonNSString.ToString();
+
return Json.Deserialize(jsonString) as Dictionary;
}
- public static Dictionary NSDictToPureStringDict(NSDictionary nsDict)
+ public static Dictionary? NSDictToPureStringDict(NSDictionary? nsDict)
{
- if (nsDict == null)
+ var jsonString = SerializeToJsonString(nsDict);
+ if (jsonString == null)
return null;
- NSError error;
- NSData jsonData = NSJsonSerialization.Serialize(nsDict, 0, out error);
- NSString jsonNSString = NSString.FromData(jsonData, NSStringEncoding.UTF8);
- string jsonString = jsonNSString.ToString();
- return JsonSerializer.Deserialize>(jsonString);
+
+ return DeserializeStringDictionary(jsonString);
}
public static Notification ToNotification(OneSignaliOS.OSNotification notification)
@@ -53,7 +45,7 @@ public static Notification ToNotification(OneSignaliOS.OSNotification notificati
Dictionary additionalDataXam = new Dictionary();
if (notification.AdditionalData != null)
{
- additionalDataXam = NSDictToPureDict(notification.AdditionalData);
+ additionalDataXam = NSDictToPureDict(notification.AdditionalData) ?? additionalDataXam;
}
List actionButtonsXam = new List();
@@ -61,7 +53,7 @@ public static Notification ToNotification(OneSignaliOS.OSNotification notificati
{
foreach (NSObject actionButton in notification.ActionButtons)
{
- Dictionary actionButtonXam = NSObjectToPureDict(actionButton);
+ Dictionary? actionButtonXam = NSObjectToPureDict(actionButton);
if (actionButtonXam != null)
{
actionButtonsXam.Add(
@@ -123,4 +115,31 @@ public static InAppMessage ToInAppMessage(OneSignaliOS.OSInAppMessage inAppMessa
{
return new InAppMessage(messageId: inAppMessage.MessageId);
}
+
+ private static string? SerializeToJsonString(NSObject? nSObject)
+ {
+ if (nSObject == null)
+ return null;
+
+ NSData jsonData = NSJsonSerialization.Serialize(nSObject, 0, out _);
+ if (jsonData == null)
+ return null;
+
+ NSString? jsonNSString = NSString.FromData(jsonData, NSStringEncoding.UTF8);
+ return jsonNSString?.ToString();
+ }
+
+ private static Dictionary? DeserializeStringDictionary(string jsonString)
+ {
+ if (Json.Deserialize(jsonString) is not Dictionary parsed)
+ return null;
+
+ var result = new Dictionary();
+ foreach (var entry in parsed)
+ {
+ result[entry.Key] = entry.Value?.ToString() ?? string.Empty;
+ }
+
+ return result;
+ }
}
diff --git a/OneSignalSDK.DotNet.iOS/Utilities/ToNativeConversion.cs b/OneSignalSDK.DotNet.iOS/Utilities/ToNativeConversion.cs
index 161a2fa0..bba88e8f 100644
--- a/OneSignalSDK.DotNet.iOS/Utilities/ToNativeConversion.cs
+++ b/OneSignalSDK.DotNet.iOS/Utilities/ToNativeConversion.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Foundation;
-using HomeKit;
using OneSignalSDK.DotNet.Core;
using OneSignalSDK.DotNet.Core.Internal.Utilities;
@@ -11,7 +10,7 @@ namespace OneSignalSDK.DotNet.iOS.Utilities;
///
public static class NativeConversion
{
- public static NSDictionary DictToNSDict(IDictionary dict)
+ public static NSDictionary? DictToNSDict(IDictionary? dict)
{
if (dict == null)
return null;
@@ -22,17 +21,15 @@ public static NSDictionary DictToNSDict(IDictionary(keys, values);
-
- return result;
+ return new NSDictionary(keys, values);
}
- public static NSDictionary DictToNSDict(IDictionary dict)
+ public static NSDictionary? DictToNSDict(IDictionary? dict)
{
if (dict == null)
return null;
@@ -42,17 +39,15 @@ public static NSDictionary DictToNSDict(IDictionary(keys, values);
-
- return result;
+ return new NSDictionary(keys, values);
}
- public static NSObject ListToNSObject(IList