Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from fresha/threading-fixes
Browse files Browse the repository at this point in the history
Present/dismiss Apple Pay from main queue
  • Loading branch information
kondratk authored Aug 8, 2022
2 parents 4904e43 + d4d47cb commit 4701c81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions ios/Plugin/ApplePayService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class ApplePayService: NSObject {
let request = callPayload.toPKPaymentRequest()
let paymentController = PKPaymentAuthorizationController(paymentRequest: request)
paymentController.delegate = self
paymentController.present { [weak self] (presented) in
if !presented {
self?.paymentInitHandler?(.failure(.couldNotPresentSheet))
DispatchQueue.main.async {
paymentController.present { [weak self] (presented) in
if !presented {
self?.paymentInitHandler?(.failure(.couldNotPresentSheet))
}
}
}
}
Expand All @@ -59,9 +61,10 @@ class ApplePayService: NSObject {
resultHandler(.failure(.couldNotParsePaymentCompletionStatus))
return
}

paymentCompletionHandler(result)
resultHandler(.success(()))
DispatchQueue.main.async {
paymentCompletionHandler(result)
}
self.paymentCompletionHandler = nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fresha/capacitor-plugin-applepay",
"version": "1.0.1",
"version": "1.0.2",
"description": "Apple Pay plugin for Capacitor",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit 4701c81

Please sign in to comment.