Skip to content

[Bug]: In-app message language variant matching fails for zh-Hans / zh-Hant (falls back to default/English) #1741

Closed

Description

@luckychdhr

What happened?

In-app messages with language-specific variants for Chinese (zh-Hans / zh-Hant) never match and always fall back to the default variant, even when OneSignal.User.setLanguage("zh-Hans") (or "zh-Hant") is called explicitly and the User's language property is confirmed correct on the dashboard.

Root cause:
In OSInAppMessageController.m (verified in the 5.2.15 tag), the variantId category method on OSInAppMessageInternal does:

NSString *userLanguageCode = [OneSignalUserManagerImpl.sharedInstance.language substringToIndex:2];

then looks up self.variants[type][userLanguageCode]. Truncating to the first two characters is correct for tags like en-US → en, but Chinese variant keys are the full BCP-47 tags zh-Hans and zh-Hant per your own supported languages list — both truncate to "zh", which matches neither key, so the lookup falls through to variants[type][@"default"].

Steps to reproduce?

1.On react-native-onesignal 5.2.15 (OneSignalXCFramework 5.2.15), create an in-app message in the dashboard with language variants for zh-Hans (or zh-Hant) and a default variant with different content.
2.In the app, call OneSignal.User.setLanguage("zh-Hans") before the message is expected to trigger.
3.Confirm on the dashboard/User record that the language is correctly stored as zh-Hans.
4.Trigger the in-app message on iOS.
5.For comparison: the equivalent Android app (same OneSignal setup, same language) correctly shows the zh-Hans variant.

What did you expect to happen?

Expected: The zh-Hans variant content is shown.
Actual: The default variant content is shown (in our case, English). Android is unaffected.

OneSignal iOS SDK version

5.2.15

iOS version

26

Specific iOS version

IOS 26.3

Relevant log output

Code of Conduct

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

Activity

  1. fadi-george commented on Sep 14, 2026

    @fadi-george
    Collaborator

    Thanks for the report, we'll take a look.

  2. fadi-george commented on Sep 14, 2026

    @fadi-george
    Collaborator

    @luckychdhr could you reach out to our support team and give us your app id? Mention "SDK-5202".

  3. luckychdhr commented on Sep 14, 2026

    @luckychdhr
    Author

    @fadi-george Sure, I will do that. No worries.

  4. luckychdhr commented on Sep 16, 2026

    @luckychdhr
    Author

    @fadi-george Any update on this, as I got no response from the support team from last 2 days and we don't want to add any patch on our side. Can you give me estimated time.

  5. fadi-george commented on Sep 16, 2026

    @fadi-george
    Collaborator

    @luckychdhr we'll be looking into long term sdk side fixes. But I believe we've deployed a short-term server side fix for this issue. Could you check?

  6. luckychdhr commented on Sep 16, 2026

    @luckychdhr
    Author

    Let me check and get back to you @fadi-george

  7. luckychdhr commented on Sep 16, 2026

    @luckychdhr
    Author

    Its working now. Thanks @fadi-george

  8. fadi-george commented on Sep 16, 2026

    @fadi-george
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions