Skip to main content
Answer

iOS Swift SDK - Offering Metadata type casting errors

  • July 19, 2023
  • 2 replies
  • 150 views

Forum|alt.badge.img+4

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.

This post has been closed for comments

2 replies

Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • 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
  • 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.