Use StoreKit 2 my client IAP code like this:
func purchase(_ product: Product) async throws -> Transaction? {
let orderId = UUID.init()
let result = try await product.purchase(options: [.appAccountToken(orderId)])
switch result {
case .success(let verification) :
let transaction = try checkVerified(verification)
//Here can I tell my server deliver content to user?
//I do not want valid transaction on device(just like valid receipt via S2S use Storekit1)
return transaction
case .userCancelled, .pending:
return nil
default:
return nil
}
}
If verificationResult return ..verified() case , can I tell my server deliver content to my customer ?
Or should I send originalID for this transaction to my server, my server has to fetch transaction info by history Api(decode JWS info) to decide whether to deliver content to my custom?
Thank you very much
Post
Replies
Boosts
Views
Activity
Hi
My App has realize IAP function by StoreKit1, the flow just like this:
1.My app purchase one product by storekit1
2.When user has purchased, my app receive purchased transaction object
3.App send local device receipt to my server
4.My server use verifyReceipt Api to get transaction info, So my server can delivery product to current user
But With StoreKit2 how my server valid purchase?
1.Plan A
func checkVerified<T>(_ result: VerificationResult<T>) throws -> T {
//Check if the transaction passes StoreKit verification.
switch result {
case .unverified:
//StoreKit has parsed the JWS but failed verification. Don't deliver content to the user.
throw NTESiTAStoreError.failedVerification
case .verified(let safe):
//If the transaction is verified, unwrap and return it.
return safe
}
}
then i can get the transacation:
let transaction = try checkVerified(result)
let jwsString = result.jwsRepresentation;
what can i do next?
Send the original_id to my server, then my server request get purchase history Api to get transaction JWS to decode to delivery product?
or my client can send some information about result or transaction from checkVerified func to my server, then my server do not need to fetch transaction info from apple server , it can delivery product directly?
Plan B
Can i get JWS String from result or transaction from checkVerified func like
eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoidGVzdCJ9.pNIWIL34Jo13LViZAJACzK6Yf0qnvT_BuwOxiMCPE-Y
where can i receive this?
when i receive it I will send it to my server , my server decode it delivery product directly without request get history API?
I'm confused, because i am first time to change IAP SDK in my app, I need some suggest and guide.
Thank you very much
I just enter one oritransactionid to app store server, but why I can reveive a array for signedTransactions?
One oritransactionid can corresponding many purchases via user?
Thank you very much
Hello Everyone
In my OC project, I have create a widget extension
and in my main app I need to know all my widget info
So I create a swift file to import widget kit.
Debug is fine but archive can not success with error
Cannot find 'WidgetCenter' in scope
Anyone can help me?
Learning Keeping a Widget Up To Date I know I can show Text with a dynamic time, but It's a fixed format like 32sec or 2 hours 23 minutes
How can I just show "23 minutes ago" without second string?
Thanks for help me
Today I Archived testFlight to test my widget
But my widget did not appeared in widget library so i can not add it to my device screen
I have changed Api already
IntentConfiguration(kind: kind, intent: Intent.self, provider: Provider()) { entry in
EntryView(entry: entry)
}
Is there a bug with this scene?
Hi
I change my widget func to
IntentConfiguration(kind: kind, intent: ***, provider: Provider())
{ entry in
EntryView(entry: entry)
}
by removing placeholder parameter
And i also add func to my provider to return an Entry
func placeholder(with: Context) -> FeedModelEntry
So where I should add this modifier to indicate this view should look likes placeholderView style?
.redacted(reason: .placeholder)
My widget has three line text , but after add placeholder(with: Context) i can not see my view change to placeholder view style when i edited my widget
Should my entry object need hold a isPlaceholder property to let my widget view to know it should show placeholder style?
if entry.isPlaceHolderView {
someView()
.redacted(reason: .placeholder)
} else {
someView()
}
Thank you very much
Xcode-beta3
My needs are download images for my widget, and i also know in my custom swiftUI view loading in the body is not allowed.
When I received remote data, I download each one in imageurls array. My widget need to show three titles for three images, How Can I connect them one by one?(one title has an image)
Is there any demo project for me to learn?
Thank you very much
I need to change My remote image color from network, so should I use UIImage?
For example:
let colors = UIImage(named: "demo9")!.getColors()
Image("demo9").resizable()
.clipShape(ContainerRelativeShape())
Thank you very much