I'm trying to get IAP Price to be displayed on a button and it should be based on the location user is from. For eg, if the user is from US, the button should show 'Buy for $0.99'. if they are from India, it should say 'Buy for Rs.81.57'. I've used the below code based on Google Search and Youtube Tutorials using Package. However, I'm unable to pass a value as Package to the view where the button is located and Package is declared.
Snippet of the code :
struct In_AppPurchaseView: View {
let package : Package
var body: some View {
ZStack{
Button("Buy for \(package.localizedPriceString)") {
// additional code
}
}
}
}
View where In-App purchase view is called
struct SupportView: View {
var body: some View {
// passed as a sheet when clicking a button
Button("Premium"){
}
.sheet(isPresented: $showSheet) {
In_AppPurchaseView(vm: vm) // this is where I'm having trouble to pass value of type Package.
}
}
}
is there any other way to show the price in local currency value for user's region on a button?
Thanks in advance.