Implementing GraphQL in an iOS application

Introduction I previously never had a chance to work with GraphQL. I was excited to learn when to apply this technology, what tools I can use, and how I can implement it. Here’s what I found: For testing, I used the Star Wars GraphQL API with AllFilmsQuery: query AllFilmsQuery { allFilms { films { title director created producers releaseDate } } } I requested allFilms with title, director, created, producers, and releaseDate information. ...

May 15, 2024 · 3 min · Dmytro Chumakov

Securing user data with Keychain, Touch ID, and Face ID

Introduction I was eager to learn about securing user data using Keychain and biometric authentication. Here are a few steps I found: Caveats You can test accessing Keychain data using Touch ID and Face ID only on a real device. First Step The first step is to add the Privacy - Face ID Usage Description key to your Info.plist. Without it, you would not be able to retrieve data from Keychain using Face ID. ...

May 13, 2024 · 4 min · Dmytro Chumakov

Implementing In-App Purchases to SwiftUI app using StoreKit 2

Introduction I was wondering how to add in-app purchases to my app. I chose non-consumable in-app purchase because you can pay one time for this item. Here are a few steps on how I did it. First Step Set up In-App Purchases for your app in App Store Connect account or add a .storekit configuration file and start from there. If you’ve already set up In-App Purchases in your account, you can sync the StoreKit config with that data. ...

May 12, 2024 · 3 min · Dmytro Chumakov

Implementing Apple Pay in a SwiftUI app

Introduction Sometime ago, I was working on a marketplace app, and I needed to add Apple Pay to make purchases more easily. Here are a few steps on how I did it: First Step You need to add Apple Pay capability to your project. You will need to Register a Merchant ID. I will skip this step; you can find info by following this link Setting up Apple Pay. Second Step You will need to import PassKit and create PKPaymentRequest to interact with PKPaymentAuthorizationController and PKPaymentAuthorizationControllerDelegate. func initiateApplePay() { // Create payment request let paymentRequest = PKPaymentRequest() paymentRequest.merchantIdentifier = "your_merchant_identifier" paymentRequest.countryCode = "US" paymentRequest.currencyCode = "USD" paymentRequest.supportedNetworks = [.visa, .masterCard, .amex] paymentRequest.merchantCapabilities = .threeDSecure // Add payment items from cart for item in cartItems { let paymentItem = PKPaymentSummaryItem(label: item.name, amount: item.price) paymentRequest.paymentSummaryItems.append(paymentItem) } // Add total amount let totalItem = PKPaymentSummaryItem(label: "Total", amount: totalAmount) paymentRequest.paymentSummaryItems.append(totalItem) // Present Apple Pay sheet let paymentController = PKPaymentAuthorizationController(paymentRequest: paymentRequest) paymentController.delegate = self paymentController.present(completion: nil) } Third Step Add UI and connect it with the view model. ...

May 11, 2024 · 3 min · Dmytro Chumakov

Integration testing for SwiftUI views

Introduction I have been looking for information about implementation details of integration testing. I found a lot of information, but it was theoretical and all information looked the same. I did not find a meaningful example, so I tried to come up with my own definition and sample. Integration testing means testing the behavior between modules or views to ensure they work as expected after user actions. There are two ways of conducting integration testing: The first is by unit tests, where you try to test the flowing data between view models. The second is UI tests, where you try to test if the UI items exist and navigation works correctly. I will focus on testing the flowing data between view models. ...

May 10, 2024 · 2 min · Dmytro Chumakov