Skip to main content
Solved

iOS Swift SDK - Offering Metadata type casting errors


Forum|alt.badge.img+3
  • New Member
  • 3 replies

Recently we’ve started integrate the Offering Metadata feature. As this is a beta feature, I believe there is a minor bug in the SDK.

 

Reproduction Steps:

  1. Add an integer property into metadata of the offering using RevenueCat dashboard (“myProperty” : 123)
  2. Try to read the the integer value using in Swift code: offering?.getMetadataValue(for: "myProperty", default: -1)
  3. The value defaults to -1 rather than 123

 

When I checked the SDK code, I see that the metadata dictionary returned as [“myProperty: “123”]. Then getMetadataValue<T>(for key: String, default: T) -> T function is failing to cast the value to Int even though generic value T is set to Int in above call.

 

It is not a major issue as I can achieve casting in my code but wanted to report it here.

 

I am using:

Swift 5

Xcode 14.3.1

RevenueCat 4.25.0

 

Best answer by NachoSoto

Hi @berk,

Good news: the RevenueCat team has been busy at work revamping Metadata, so you can now set a completely custom JSON:

This means that you can now specify the type that you want, so the SDK will be able to read it as an Int.

Let us know if you have any further questions.

Thanks.

View original
Did this post help you find an answer to your question?

2 replies

Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • 382 replies
  • July 21, 2023

Hey @berk ,

 

Thanks for reporting this. I went ahead and shared it with the rest of the engineering team and will let you know what I have any more information on this. 


NachoSoto
Forum|alt.badge.img+5
  • Active Helper
  • 22 replies
  • Answer
  • August 2, 2023

Hi @berk,

Good news: the RevenueCat team has been busy at work revamping Metadata, so you can now set a completely custom JSON:

This means that you can now specify the type that you want, so the SDK will be able to read it as an Int.

Let us know if you have any further questions.

Thanks.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings