-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-String Subscriber Attributes Crashes App #499
Comments
Hi! 👋 Thanks for opening. Our API does specify that the input type of that method is supposed to be: https://github.com/RevenueCat/purchases-ios/blob/develop/Purchases/Public/RCPurchases.h#L414 And in fact, if you attempt to send a non-string in Objective-C, you get a build warning: And in Swift you get a compilation error: However, these are Lightweight Generics in Objective-C, and depending on how you're sending over the values, the compiler might not catch the issue. Could you shed some light on how you came across the issue? Was this while using |
Hi @aboedo Sorry, I should have specified. The bug/crashes occurs within To replicate, you can run this in JavaScript with the Cordova plugin installed;
This will then crash Do you want me to move this over to the Cordova repo? It could be bulletproofed from both the JavaScript (to force a string value, or throw an error) but also dynamic type checking in Objective-C. Cheers, |
@Ralpharoo that makes sense. We do have the type documented in |
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Please reach out if you have additional information to help us investigate further! |
This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports. |
Describe the bug
When setting attributes if a numeric value is provided, the value is saved to
UserDefaults
as anNSNumber
I.e.When called a second time the
storeAttributeLocallyIfNeededWithKey
method loads theNSNumber
value but compares it as anNSString
usingisEqualToString
, which crashes the device.The app then needs to be deleted, before it can ever be used again as this occurs every time the app loads (as we set this value while loading our user objects).
If the intention is to only support string values (which is fine by us), then I'd suggest either casting all inputs as a string before saving or, throwing an error so we know this is not allowed while developing.
We are now casting everything as a string before calling
setAttributes
but someone else might trip over this like we did;Thanks! 👍
The text was updated successfully, but these errors were encountered: