-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push notification extensions in example
- Loading branch information
Showing
39 changed files
with
602 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Foundation; | ||
using Newtonsoft.Json; | ||
|
||
namespace Bloomreach.Platforms.iOS; | ||
|
||
public class NSObjectConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return typeof(NSObject).IsAssignableFrom(objectType); | ||
} | ||
|
||
public override bool CanRead => false; | ||
|
||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) | ||
{ | ||
if (value == null) | ||
{ | ||
return; | ||
} | ||
if (value is NSDictionary dictionary) | ||
{ | ||
writer.WriteStartObject(); | ||
foreach (var pair in dictionary) | ||
{ | ||
if (pair.Key == null || pair.Value == null) continue; | ||
writer.WritePropertyName(pair.Key.ToString()); | ||
serializer.Serialize(writer, pair.Value); | ||
} | ||
writer.WriteEndObject(); | ||
return; | ||
} | ||
if (value is NSArray array) | ||
{ | ||
writer.WriteStartArray(); | ||
foreach (var item in array) | ||
{ | ||
if (item == null) continue; | ||
serializer.Serialize(writer, item); | ||
} | ||
writer.WriteEndArray(); | ||
return; | ||
} | ||
if (value is NSNull nsNull) | ||
{ | ||
writer.WriteNull(); | ||
return; | ||
} | ||
writer.WriteValue(value.ToString()); | ||
} | ||
|
||
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
Oops, something went wrong.