OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

[Bug]: iOS - Using DeleteTags to remove multiple tags fails with a json validation error #372

Closed matthewrdev closed 1 year ago

matthewrdev commented 1 year ago

What happened?

On iOS, when using the OneSignal.Default.DeleteTags method, it fails with the following issue:

2023-03-22 10:44:02.065124+1000 REDACTED.iOS[8819:230185] WARNING: sendTags JSON Invalid: The following key/value pairs you attempted to send as tags are not valid JSON: {
    user = "";
    "<null>" = "";
}

The user and <null> tags are two tags not provided by my code through the DeleteTags method.

I can work around this by deleting each tag one-by-one, however this results in many more HTTP requests and takes much longer:


foreach (var tag in tags)
{
   await OneSignal.Default.DeleteTag(tag);
}

Steps to reproduce?

1. Add several tags to an account using the `SendTags` method. 
2. Delete these tags using `DeleteTags`.

Example:

var myTags = new string[] { "Alpha", "Beta", "Zeta" };
await OneSignal.Default.SendTags(tags)
await Task.Delay(10_000); // Simulate some work.
await OneSignal.Default.DeleteTags(myTags);

### What did you expect to happen?

I expect that calling `OneSignal.Default.DeleteTags` works and does not fail with a json error.

### OneSignal Xamarin SDK version

4.3.3

### Which platform(s) are affected?

- [X] iOS
- [ ] Android

### Relevant log output

```Shell
2023-03-22 10:44:02.065124+1000 REDACTED.iOS[8819:230185] WARNING: sendTags JSON Invalid: The following key/value pairs you attempted to send as tags are not valid JSON: {
    user = "";
    "<null>" = "";
}

Code of Conduct

brismithers commented 1 year ago

Hi @matthewrdev , I've confirmed this as a bug and hope to have a fix soon.

brismithers commented 1 year ago

This has been released via v4.3.4

matthewrdev commented 1 year ago

Thanks for the quick turnaround @brismithers!