Skip to content

fix: use enum values for userStatus instead of string on android#13

Merged
Gautham495 merged 5 commits into
Gautham495:mainfrom
osilviotti:fix/user-status-type-fix
May 28, 2026
Merged

fix: use enum values for userStatus instead of string on android#13
Gautham495 merged 5 commits into
Gautham495:mainfrom
osilviotti:fix/user-status-type-fix

Conversation

@osilviotti

@osilviotti osilviotti commented May 20, 2026

Copy link
Copy Markdown
Contributor

When running yarn example android I was getting the following error preventing the build from completing:

e: file:///path/react-native-play-age-range-declaration/android/src/main/java/com/margelo/nitro/playagerangedeclaration/PlayAgeRangeDeclaration.kt:56:32 Argument type mismatch: actual type is 'String?', but 'PlayAgeRangeDeclarationUserStatusValues?' was expected.

I believe it came in with #10 when the type of userStatus was changed from String to PlayAgeRangeDeclarationUserStatusValues.

I've updated the user status check to explicitly return enum values, and the app now builds and runs on my Android device.

I don't have an iOS device to test on and it looks like a similar issue exists there with statusString being typed as a String rather than AppleAgeRangeDeclarationUserStatusValues (here) but didn't want to make any changes that I couldn't test.

Note: I haven't worked with Nitro Modules before - I only committed the generated files that had diffs, happy to update the PR if I've done this wrong

@Gautham495

Copy link
Copy Markdown
Owner

The android side works - @osilviotti - Can you try to upgrade the nitro package to 35.4+ so it will generate new nitro files for iOS.

@osilviotti

Copy link
Copy Markdown
Contributor Author

Just added all the other generated files @Gautham495

@Gautham495

Copy link
Copy Markdown
Owner

@osilviotti - Thanks for the change, but there is an issue with the iOS types.

This was not present before.

@osilviotti

Copy link
Copy Markdown
Contributor Author

@Gautham495 I think that's because the types were changed in #10 without running yarn nitrogen - I haven't changed any iOS files.

I can make the changes to the Swift file if you're happy to test it

@Gautham495

Copy link
Copy Markdown
Owner

The iOS side is not building which will cause issues, I will check this out - @osilviotti

@Gautham495

Copy link
Copy Markdown
Owner

I am not finding the time for this - @osilviotti - I will let you know once done.

@osilviotti

Copy link
Copy Markdown
Contributor Author

@Gautham495 I have got an iOS dev environment now so I can take a look. From first glance it looks like the issue is around this:

export type PlayAgeRangeDeclarationUserStatusValues =
(typeof PlayAgeRangeDeclarationUserStatus)[keyof typeof PlayAgeRangeDeclarationUserStatus];

The type is a union of numeric strings which nitrogen parses into values which are read as floats by Swift (here)

I'll see if I can find a way around this

@Gautham495

Copy link
Copy Markdown
Owner

If you can bring a fix, do let me know, i will merge the changes.

For compatibility with Xcode 26.4
@osilviotti osilviotti force-pushed the fix/user-status-type-fix branch 2 times, most recently from c59ef57 to d2f81ff Compare May 28, 2026 00:15
@osilviotti osilviotti force-pushed the fix/user-status-type-fix branch from d2f81ff to b7be347 Compare May 28, 2026 00:18
@osilviotti

osilviotti commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

The build now works for me locally on iOS - I went with replacing the PlayAgeRangeDeclarationStatus object with an enum and that seems to have done the trick

@Gautham495

Copy link
Copy Markdown
Owner

Thanks for the fix - @osilviotti - I have merged your changes - Thanks for taking the time to improve the library!

Grateful for your help.

@Gautham495 Gautham495 merged commit 9239671 into Gautham495:main May 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants