This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const appBridge = { | |
initialize: function () { | |
if (window.location.host.indexOf('web-demo') !== -1) | |
return; | |
console.log('initialize appBridge'); | |
appBridge.parseDom(); | |
window.addEventListener("message", (event) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Booking": { | |
"BookingUuid": "cee3384c-3155-4684-ad06-b9a1ee134e5b", | |
"Name": "ellinaclient", | |
"Start": "2022-06-16T12:00:00Z", | |
"End": "2022-06-16T13:00:00Z", | |
"Machines": [ | |
"3b8eb5ff-e9ae-4d42-9e3b-7c63d72a1dc3" | |
], | |
"WithCoupons": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Swift.Error) { | |
self.delegate?.inAppLoadingFailed(error: error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func restoreSubscription() { | |
SKPaymentQueue.default().restoreCompletedTransactions() | |
self.delegate?.inAppLoadingStarted() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RTSubscriptionResponse: Mappable { | |
var expirationDate: Date? | |
var isTrial: Bool? | |
var productId: String? | |
required convenience init?(map: Map) { | |
self.init() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func purchaseProduct(productType: ProductType) { | |
guard let product = self.products.filter({$0.productIdentifier == productType.rawValue}).first else { | |
self.delegate?.inAppLoadingFailed(error: InAppErrors.noProductsAvailable) | |
return | |
} | |
let payment = SKMutablePayment(product: product) | |
SKPaymentQueue.default().add(payment) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension InAppManager: SKProductsRequestDelegate { | |
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) { | |
self.products = response.products | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loadProducts() { | |
let productIdentifiers = Set<String>(ProductType.all.map({$0.rawValue})) | |
let request = SKProductsRequest(productIdentifiers: productIdentifiers) | |
request.delegate = self | |
request.start() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum ProductType: String { | |
case weekly = "com.example.app.weekly" | |
case monthly = "com.example.app.monthly" | |
case yearly = "com.example.app.yearly" | |
static var all: [ProductType] { | |
return [.weekly, .monthly, .yearly] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InAppManager: NSObject { | |
static let shared = InAppManager() | |
} | |
extension InAppManager: SKPaymentTransactionObserver {} | |
extension InAppManager: SKProductsRequestDelegate {} |
NewerOlder