Solved

iOS Swift SDK - Offering Metadata type casting errors

  • 19 July 2023
  • 2 replies
  • 83 views

Badge +3

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

 

icon

Best answer by NachoSoto 2 August 2023, 23:16

View original

2 replies

Userlevel 4
Badge +6

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. 

Userlevel 1
Badge +5

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