@@ -12,13 +12,14 @@ import RustXcframework
1212public func ios_iap_products( products: RustVec < RustString > )
1313{
1414 Task {
15+ //TODO: wrap in do catch for error handling
16+
1517 var productIds : [ String ] = [ ]
1618 for p in products {
1719 productIds. append ( p. as_str ( ) . toString ( ) )
1820 }
1921
2022 let products = try await Product . products ( for: productIds)
21- // print("products:\n \(products)")
2223
2324 let rust_products = RustVec < IosIapProduct > ( )
2425
@@ -46,7 +47,12 @@ public func ios_iap_purchase(id: RustString)
4647 do {
4748 let productIds = [ id. toString ( ) ]
4849 let products = try await Product . products ( for: productIds)
49- let purchase = try await products [ 0 ] . purchase ( )
50+
51+ if products. isEmpty {
52+ return purchase_processed ( IosIapPurchaseResult . unknown ( id. toString ( ) ) )
53+ }
54+
55+ let purchase = try await products. first!. purchase ( )
5056
5157 let result = switch purchase {
5258 case . success( _) :
@@ -60,7 +66,6 @@ public func ios_iap_purchase(id: RustString)
6066
6167 purchase_processed ( result)
6268 } catch {
63- print ( " ios_iap_purchase error: \( error) . " )
6469 purchase_processed ( IosIapPurchaseResult . error ( error. localizedDescription) )
6570 }
6671 }
@@ -88,15 +93,16 @@ public func ios_iap_transaction_finish(id: UInt64) {
8893 }
8994
9095 transaction_finished ( IosIapTransactionFinished . unknown ( id) )
91- } catch {
92- print ( " ios_iap_transaction_finish error: \( error) . " )
96+ } catch {
9397 transaction_finished ( IosIapTransactionFinished . error ( error. localizedDescription) )
9498 }
9599 }
96100}
97101
98102public func ios_iap_transactions_all( ) {
99103 Task {
104+ //TODO: wrap in do catch for error handling
105+
100106 var transactions = RustVec< IosIapTransaction> . init( )
101107
102108 for await t in Transaction . all {
0 commit comments