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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
if ProcessInfo.processInfo.arguments.contains("CLEANSTART") { | |
// Call internal method to clear existing application storage | |
resetApplicationStorage() | |
} | |
} |
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 testCallFlowFirstStart() { | |
// Re-launch the app with an argument to clear out storage | |
let app = XCUIApplication() | |
app.launchArguments.append("CLEANSTART") | |
app.launch() | |
// Rest of your test case follows.... | |
} |
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
@IBAction func testPurchasePressed(_ sender: Any) { | |
NamiPurchaseManager.skusForSKUIDs(skuIDs: ["test_product_id"], productHandler: { (_, products, _, error) in | |
// We make sure StoreKit can load the product we intend to purchase. | |
if let products = products, let product = products.first { | |
// Tell the Nami SDK to initiate a purchase via StoreKit. | |
NamiPurchaseManager.buySKU(product, responseHandler: { (purchases, _, _) in | |
if purchases.count > 0 { | |
// Success | |
DispatchQueue.main.async { | |
// Make the result available in both the text of the label and the accessibilityValue |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.transactionSentLabel?.accessibilityIdentifier = "purchaseResultLabel" | |
// Make the result available in both the text of the label and the accessibilityValue | |
self.transactionSentLabel?.text = "none" | |
self.transactionSentLabel?.accessibilityValue = "none" | |
} |
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 UnitTestingAppUITests: XCTestCase { | |
func testPurchase() { | |
// Make sure to use the StoreKit configuration file that Xcode supports for testing purchases. | |
if let session = try? SKTestSession(configurationFileNamed: "UnitTestStoreKitConfig.storekit") { | |
session.disableDialogs = true | |
session.clearTransactions() | |
} |
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
let result = await Transaction.latest(for: "myProductID") | |
switch result { | |
case .unverified: | |
// StoreKit has parsed the JWS but failed verification. Don't deliver content to the user. | |
throw StoreError.failedVerification | |
case .verified(let safe): | |
// If the transaction is verified, unwrap and return it. | |
return safe | |
} |
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
let result = try await storeProducts.first.purchase() |
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
let storeProducts = try await Product.request(with: Set("myProductID")) |
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
var body: some View { | |
VStack(spacing: 30) { | |
if !subscriptionDataSource.subscribed { | |
// if the user is not subscribed, show a subscribe button | |
Button(action: { | |
// pushing button raises a paywall with Nami | |
NamiPaywallManager.raisePaywall(fromVC: nil) | |
}) { | |
Text("Subscribe Today!") | |
.background(Color.white) |
NewerOlder