Skip to content

[Bug]: AddTags Method Does Not Work Sometimes #1585

@bundleberk

Description

@bundleberk

What happened?

Subject: Question about re-setting initial user tags when SDK fails to set them initially

Hello,

I'm experiencing an issue with user tag initialization in my iOS app and would like your guidance on my proposed solution.

Issue:
I'm using user tags for segmentation to send targeted push notifications. However, I've noticed that sometimes the OneSignal SDK fails to set the initial tags for users during the first attempt, and it doesn't appear to automatically retry this operation. This results in a significant number of untagged users who cannot receive notifications properly.

According to the SDK documentation, the SDK should retry when setTags fails, but this doesn't seem to be working correctly in practice. Additionally, I'm setting an external ID at nearly the same time as setting the tags, which your support team has previously mentioned could potentially cause issues.

My Proposed Solution:
To address this, I've implemented a check that:

  1. Retrieves the current tags from the OneSignal SDK
  2. If the tags are empty, re-attempts to set the initial tags again

Questions:

  1. Are there any risks or potential issues with this approach?
  2. Will re-setting tags that should have been set initially cause any conflicts or unexpected behavior?
  3. Is this a known issue with the SDK's retry mechanism for failed tag setting?
  4. Could the timing of setting external ID and tags simultaneously be causing the tag setting to fail?
  5. Would you recommend any alternative approaches to ensure reliable tag setting, such as delaying one operation or implementing a specific sequence?

I want to make sure this solution won't cause any problems with user segmentation, notification delivery, or data consistency before implementing it in production.

Steps to reproduce?

1. Initialize SDK
2. call addTags() with a bunch of tags.

What did you expect to happen?

I expect to set the tags successfully.

OneSignal iOS SDK version

Release 5.1.15

iOS version

18, 17, 16, 15

Specific iOS version

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions