You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Making a call to OneSignal.Default.SendTags(myTags) results in a System.InvalidCastException with a message of "Specified cast is not valid."
Environment
Visual Studio 2022
Xamarin 17.2.0.177
OneSignalSDK.Xamarin 4.1.0
Installed via nuget
Steps to Reproduce Issue:
Start a new Xamarin Forms blank project
Install OneSignalSDK.Xamarin 4.1.0
Add initialization code following documentation
Make an awaited call to OneSignal.Default.SendTags and supply a dictionary with tags and values.
Anything else:
In digging through code for SendTags in the Android implementation, it appears that in November the method was changed from directly supplying a string of JSON data, to serializing the dictionary to a string and then attempting to cast it to a JSONObject.
This throws an invalid cast exception as it can't cast from the string returned from the serializer to JSONObject. Perhaps a better approach would be to use the JSONObject constructor that accepts a JSON string as a parameter?
An additional note is that due to a bug in Xamarin.Android at the moment, the exception is currently being returned as a null reference exception if it is awaited and not wrapped in a try/catch.
Stack Trace:
at OneSignalSDK.Xamarin.OneSignalImplementation.SendTags (System.Collections.Generic.Dictionary`2[TKey,TValue] tags) [0x00010] in /Users/tanay/Desktop/OneSignal/OneSignal-Xamarin-SDK/OneSignalSDK.Xamarin.Android/OneSignalImplementation.cs:169
at OneSignalTest.App.OnStart () [0x0004f] in C:\dev\OneSignalTest\OneSignalTest\OneSignalTest\App.xaml.cs:35
Description:
Making a call to OneSignal.Default.SendTags(myTags) results in a System.InvalidCastException with a message of "Specified cast is not valid."
Environment
Visual Studio 2022
Xamarin 17.2.0.177
OneSignalSDK.Xamarin 4.1.0
Installed via nuget
Steps to Reproduce Issue:
Anything else:
In digging through code for SendTags in the Android implementation, it appears that in November the method was changed from directly supplying a string of JSON data, to serializing the dictionary to a string and then attempting to cast it to a JSONObject.
OneSignalNative.SendTags((JSONObject)Json.Serialize(tags), handler);
This throws an invalid cast exception as it can't cast from the string returned from the serializer to JSONObject. Perhaps a better approach would be to use the JSONObject constructor that accepts a JSON string as a parameter?
An additional note is that due to a bug in Xamarin.Android at the moment, the exception is currently being returned as a null reference exception if it is awaited and not wrapped in a try/catch.
Stack Trace:
at OneSignalSDK.Xamarin.OneSignalImplementation.SendTags (System.Collections.Generic.Dictionary`2[TKey,TValue] tags) [0x00010] in /Users/tanay/Desktop/OneSignal/OneSignal-Xamarin-SDK/OneSignalSDK.Xamarin.Android/OneSignalImplementation.cs:169
at OneSignalTest.App.OnStart () [0x0004f] in C:\dev\OneSignalTest\OneSignalTest\OneSignalTest\App.xaml.cs:35
Reproduction project attached.
OneSignalTest.zip
The text was updated successfully, but these errors were encountered: