Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b126a15
pigeon stuff
LouiseHsu Sep 3, 2024
ae9095a
refactored AND working heh
LouiseHsu Sep 4, 2024
c38b66f
format
LouiseHsu Sep 4, 2024
268a50e
pre refactor for cache
LouiseHsu Sep 4, 2024
f6ec07a
.
LouiseHsu Sep 4, 2024
aa36dfd
fix configuration file
LouiseHsu Sep 5, 2024
8724d40
more docs
LouiseHsu Sep 5, 2024
a6cbd98
more docs and clean up
LouiseHsu Sep 5, 2024
b75eec7
.
LouiseHsu Sep 13, 2024
4d2fd59
FIXED TESTING ISSUE
LouiseHsu Sep 24, 2024
aeef979
native tests are donesies
LouiseHsu Sep 25, 2024
acf499f
moreeee clean up and tests,
LouiseHsu Sep 26, 2024
c3c7204
format, comments, remove prints
LouiseHsu Sep 26, 2024
9021b6f
versioning, analyze
LouiseHsu Sep 26, 2024
666df56
symlink the test files
LouiseHsu Sep 26, 2024
97b746f
fix mac cant build
LouiseHsu Sep 26, 2024
add5bf5
podspec, licensing
LouiseHsu Sep 26, 2024
06b42d0
.
LouiseHsu Sep 27, 2024
0701d2a
remove any to get around old linter
LouiseHsu Sep 27, 2024
8f225c0
remove more anys to appease format gods
LouiseHsu Sep 27, 2024
2c6efdb
Merge branch 'main' into iap_add_purchase
LouiseHsu Sep 27, 2024
72ce51c
a lil bit of refactioring
LouiseHsu Oct 1, 2024
2e940fe
Merge branch 'iap_add_purchase' of github.com:LouiseHsu/packages into…
LouiseHsu Oct 1, 2024
442c158
better error messages
LouiseHsu Oct 1, 2024
f48510b
some refactoring
LouiseHsu Oct 1, 2024
6076bf1
.
LouiseHsu Oct 1, 2024
d8dcad2
remove uneeded filed
LouiseHsu Oct 2, 2024
9c2893b
oops pathing
LouiseHsu Oct 2, 2024
1a74fb7
.
LouiseHsu Oct 2, 2024
1b688ae
.
LouiseHsu Oct 2, 2024
74c2de3
.
LouiseHsu Oct 4, 2024
71c9a1b
.
LouiseHsu Oct 4, 2024
582156b
no message
LouiseHsu Oct 4, 2024
e6bec70
.
LouiseHsu Oct 7, 2024
80795b9
.
LouiseHsu Oct 7, 2024
66362c3
.
LouiseHsu Oct 8, 2024
e554f5e
rename getter
LouiseHsu Oct 8, 2024
5a08a58
.
LouiseHsu Oct 8, 2024
0428829
try embeding?
LouiseHsu Oct 8, 2024
7c38281
rerun tests
LouiseHsu Oct 8, 2024
ec5c05c
change files so theyre relative to project rather than group
LouiseHsu Oct 10, 2024
44bcde2
.
LouiseHsu Oct 14, 2024
192b004
change from symlink
LouiseHsu Oct 15, 2024
63be3ea
.
LouiseHsu Oct 15, 2024
edead37
-m "revert"
LouiseHsu Oct 15, 2024
3ece0be
Revert "change from symlink"
LouiseHsu Oct 15, 2024
1681503
remove dev team?
LouiseHsu Oct 15, 2024
1f6957f
.
LouiseHsu Oct 15, 2024
abca747
.
LouiseHsu Oct 15, 2024
d22f360
try without test files at all
LouiseHsu Oct 16, 2024
f47a111
pls
LouiseHsu Oct 16, 2024
dbc619c
remove tests again
LouiseHsu Oct 16, 2024
7eb3d9d
Revert "remove tests again"
LouiseHsu Oct 16, 2024
1af5bff
link both storekittest and storekit
LouiseHsu Oct 16, 2024
32458c3
remove mac tests
LouiseHsu Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moreeee clean up and tests,
  • Loading branch information
LouiseHsu committed Sep 26, 2024
commit acf499ff01d0903e3a5911ee8b74dd35318a8b32
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ extension InAppPurchasePlugin: InAppPurchase2API {
.success(.pending))
case .userCancelled:
completion(
.success(.userCancelled))
.failure(
PigeonError(
code: "storekit2_purchase_cancelled",
message: "this transaction has been cancelled", details: "")))
@unknown default:
fatalError()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class PigeonError: Error {
var localizedDescription: String {
return
"PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
}
}
}

private func wrapResult(_ result: Any?) -> [Any?] {
Expand Down Expand Up @@ -59,9 +59,7 @@ private func wrapError(_ error: Any) -> [Any?] {
}

private func createConnectionError(withChannelName channelName: String) -> PigeonError {
return PigeonError(
code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.",
details: "")
return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "")
}

private func isNullish(_ value: Any?) -> Bool {
Expand Down Expand Up @@ -117,14 +115,15 @@ struct SK2SubscriptionOfferMessage {
var periodCount: Int64
var paymentMode: SK2SubscriptionOfferPaymentModeMessage



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferMessage? {
let id: String? = nilOrValue(pigeonVar_list[0])
let price = pigeonVar_list[1] as! Double
let type = pigeonVar_list[2] as! SK2SubscriptionOfferTypeMessage
let period = pigeonVar_list[3] as! SK2SubscriptionPeriodMessage
let periodCount =
pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32)
let periodCount = pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32)
let paymentMode = pigeonVar_list[5] as! SK2SubscriptionOfferPaymentModeMessage

return SK2SubscriptionOfferMessage(
Expand Down Expand Up @@ -155,10 +154,11 @@ struct SK2SubscriptionPeriodMessage {
/// The unit of time that this period represents.
var unit: SK2SubscriptionPeriodUnitMessage



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionPeriodMessage? {
let value =
pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32)
let value = pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32)
let unit = pigeonVar_list[1] as! SK2SubscriptionPeriodUnitMessage

return SK2SubscriptionPeriodMessage(
Expand All @@ -185,6 +185,8 @@ struct SK2SubscriptionInfoMessage {
/// The duration that this subscription lasts before auto-renewing.
var subscriptionPeriod: SK2SubscriptionPeriodMessage



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionInfoMessage? {
let promotionalOffers = pigeonVar_list[0] as! [SK2SubscriptionOfferMessage?]
Expand Down Expand Up @@ -228,6 +230,8 @@ struct SK2ProductMessage {
/// The currency and locale information for this product
var priceLocale: SK2PriceLocaleMessage



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductMessage? {
let id = pigeonVar_list[0] as! String
Expand Down Expand Up @@ -269,6 +273,8 @@ struct SK2PriceLocaleMessage {
var currencyCode: String
var currencySymbol: String



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2PriceLocaleMessage? {
let currencyCode = pigeonVar_list[0] as! String
Expand All @@ -292,14 +298,12 @@ struct SK2ProductPurchaseOptionsMessage {
var appAccountToken: String? = nil
var quantity: Int64? = nil



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductPurchaseOptionsMessage? {
let appAccountToken: String? = nilOrValue(pigeonVar_list[0])
let quantity: Int64? =
isNullish(pigeonVar_list[1])
? nil
: (pigeonVar_list[1] is Int64?
? pigeonVar_list[1] as! Int64? : Int64(pigeonVar_list[1] as! Int32))
let quantity: Int64? = isNullish(pigeonVar_list[1]) ? nil : (pigeonVar_list[1] is Int64? ? pigeonVar_list[1] as! Int64? : Int64(pigeonVar_list[1] as! Int32))

return SK2ProductPurchaseOptionsMessage(
appAccountToken: appAccountToken,
Expand All @@ -323,19 +327,20 @@ struct SK2TransactionMessage {
var purchasedQuantity: Int64
var appAccountToken: String? = nil
var restoring: Bool
var error: SK2ErrorMessage? = nil



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2TransactionMessage? {
let id =
pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32)
let originalId =
pigeonVar_list[1] is Int64 ? pigeonVar_list[1] as! Int64 : Int64(pigeonVar_list[1] as! Int32)
let id = pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32)
let originalId = pigeonVar_list[1] is Int64 ? pigeonVar_list[1] as! Int64 : Int64(pigeonVar_list[1] as! Int32)
let productId = pigeonVar_list[2] as! String
let purchaseDate = pigeonVar_list[3] as! String
let purchasedQuantity =
pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32)
let purchasedQuantity = pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32)
let appAccountToken: String? = nilOrValue(pigeonVar_list[5])
let restoring = pigeonVar_list[6] as! Bool
let error: SK2ErrorMessage? = nilOrValue(pigeonVar_list[7])

return SK2TransactionMessage(
id: id,
Expand All @@ -344,7 +349,8 @@ struct SK2TransactionMessage {
purchaseDate: purchaseDate,
purchasedQuantity: purchasedQuantity,
appAccountToken: appAccountToken,
restoring: restoring
restoring: restoring,
error: error
)
}
func toList() -> [Any?] {
Expand All @@ -356,6 +362,36 @@ struct SK2TransactionMessage {
purchasedQuantity,
appAccountToken,
restoring,
error,
]
}
}

/// Generated class from Pigeon that represents data sent in messages.
struct SK2ErrorMessage {
var code: Int64
var domain: String
var userInfo: [String?: Any?]? = nil



// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> SK2ErrorMessage? {
let code = pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32)
let domain = pigeonVar_list[1] as! String
let userInfo: [String?: Any?]? = nilOrValue(pigeonVar_list[2])

return SK2ErrorMessage(
code: code,
domain: domain,
userInfo: userInfo
)
}
func toList() -> [Any?] {
return [
code,
domain,
userInfo,
]
}
}
Expand Down Expand Up @@ -407,6 +443,8 @@ private class sk2_pigeonPigeonCodecReader: FlutterStandardReader {
return SK2ProductPurchaseOptionsMessage.fromList(self.readValue() as! [Any?])
case 140:
return SK2TransactionMessage.fromList(self.readValue() as! [Any?])
case 141:
return SK2ErrorMessage.fromList(self.readValue() as! [Any?])
default:
return super.readValue(ofType: type)
}
Expand Down Expand Up @@ -451,6 +489,9 @@ private class sk2_pigeonPigeonCodecWriter: FlutterStandardWriter {
} else if let value = value as? SK2TransactionMessage {
super.writeByte(140)
super.writeValue(value.toList())
} else if let value = value as? SK2ErrorMessage {
super.writeByte(141)
super.writeValue(value.toList())
} else {
super.writeValue(value)
}
Expand All @@ -471,14 +512,12 @@ class sk2_pigeonPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
static let shared = sk2_pigeonPigeonCodec(readerWriter: sk2_pigeonPigeonCodecReaderWriter())
}


/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol InAppPurchase2API {
func canMakePayments() throws -> Bool
func products(
identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void)
func purchase(
id: String, options: SK2ProductPurchaseOptionsMessage?,
completion: @escaping (Result<SK2ProductPurchaseResultMessage, Error>) -> Void)
func products(identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void)
func purchase(id: String, options: SK2ProductPurchaseOptionsMessage?, completion: @escaping (Result<SK2ProductPurchaseResultMessage, Error>) -> Void)
func transactions(completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void)
func finish(id: Int64, completion: @escaping (Result<Void, Error>) -> Void)
func startListeningToTransactions() throws
Expand All @@ -489,15 +528,9 @@ protocol InAppPurchase2API {
class InAppPurchase2APISetup {
static var codec: FlutterStandardMessageCodec { sk2_pigeonPigeonCodec.shared }
/// Sets up an instance of `InAppPurchase2API` to handle messages through the `binaryMessenger`.
static func setUp(
binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?,
messageChannelSuffix: String = ""
) {
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?, messageChannelSuffix: String = "") {
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
let canMakePaymentsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let canMakePaymentsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
canMakePaymentsChannel.setMessageHandler { _, reply in
do {
Expand All @@ -510,10 +543,7 @@ class InAppPurchase2APISetup {
} else {
canMakePaymentsChannel.setMessageHandler(nil)
}
let productsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let productsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
productsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
Expand All @@ -530,10 +560,7 @@ class InAppPurchase2APISetup {
} else {
productsChannel.setMessageHandler(nil)
}
let purchaseChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let purchaseChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
purchaseChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
Expand All @@ -551,10 +578,7 @@ class InAppPurchase2APISetup {
} else {
purchaseChannel.setMessageHandler(nil)
}
let transactionsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let transactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
transactionsChannel.setMessageHandler { _, reply in
api.transactions { result in
Expand All @@ -569,9 +593,7 @@ class InAppPurchase2APISetup {
} else {
transactionsChannel.setMessageHandler(nil)
}
let finishChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let finishChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
finishChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
Expand All @@ -588,10 +610,7 @@ class InAppPurchase2APISetup {
} else {
finishChannel.setMessageHandler(nil)
}
let startListeningToTransactionsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let startListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
startListeningToTransactionsChannel.setMessageHandler { _, reply in
do {
Expand All @@ -604,10 +623,7 @@ class InAppPurchase2APISetup {
} else {
startListeningToTransactionsChannel.setMessageHandler(nil)
}
let stopListeningToTransactionsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
let stopListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
stopListeningToTransactionsChannel.setMessageHandler { _, reply in
do {
Expand All @@ -624,9 +640,7 @@ class InAppPurchase2APISetup {
}
/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
protocol InAppPurchase2CallbackAPIProtocol {
func onTransactionsUpdated(
newTransaction newTransactionArg: SK2TransactionMessage,
completion: @escaping (Result<Void, PigeonError>) -> Void)
func onTransactionsUpdated(newTransaction newTransactionArg: SK2TransactionMessage, completion: @escaping (Result<Void, PigeonError>) -> Void)
}
class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol {
private let binaryMessenger: FlutterBinaryMessenger
Expand All @@ -638,14 +652,9 @@ class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol {
var codec: sk2_pigeonPigeonCodec {
return sk2_pigeonPigeonCodec.shared
}
func onTransactionsUpdated(
newTransaction newTransactionArg: SK2TransactionMessage,
completion: @escaping (Result<Void, PigeonError>) -> Void
) {
let channelName: String =
"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)"
let channel = FlutterBasicMessageChannel(
name: channelName, binaryMessenger: binaryMessenger, codec: codec)
func onTransactionsUpdated(newTransaction newTransactionArg: SK2TransactionMessage, completion: @escaping (Result<Void, PigeonError>) -> Void) {
let channelName: String = "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)"
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([newTransactionArg] as [Any?]) { response in
guard let listResponse = response as? [Any?] else {
completion(.failure(createConnectionError(withChannelName: channelName)))
Expand Down
Loading