Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Apr 24, 2024
2 parents 01cf729 + 517a624 commit b8420ba
Show file tree
Hide file tree
Showing 28 changed files with 1,119 additions and 693 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## 2.12.2 - 2024-04-24

[IMPROVED] Support for pending payments
[IMPROVED] Upgraded payments to StoreKit 2
[IMPROVED] Upgraded OpenVPN and OpenSSL libraries
[NOTE] Removed support for iOS 14

## 2.12.1 - 2024-02-24

[FIXED] In-app payments for legacy accounts
Expand Down
84 changes: 44 additions & 40 deletions IVPNClient.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<StoreKitConfigurationFileReference
identifier = "../../IVPNClient/Store.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Debug"
Expand Down
67 changes: 52 additions & 15 deletions IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ class AppDelegate: UIResponder {
FileSystemManager.createLogFiles()
}

private func finishIncompletePurchases() {
guard Application.shared.authentication.isLoggedIn || KeyChain.tempUsername != nil else {
return
}

IAPManager.shared.finishIncompletePurchases { serviceStatus, _ in
guard let viewController = UIApplication.topViewController() else { return }

if let serviceStatus = serviceStatus {
viewController.showSubscriptionActivatedAlert(serviceStatus: serviceStatus)
}
}
}

private func resetLastPingTimestamp() {
UserDefaults.shared.set(0, forKey: "LastPingTimestamp")
}
Expand Down Expand Up @@ -284,6 +270,11 @@ class AppDelegate: UIResponder {
}
}
}

private func startPurchaseObserver() {
PurchaseManager.shared.delegate = self
PurchaseManager.shared.startObserver()
}

}

Expand All @@ -294,10 +285,10 @@ extension AppDelegate: UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
evaluateUITests()
registerUserDefaults()
finishIncompletePurchases()
createLogFiles()
resetLastPingTimestamp()
clearURLCache()
startPurchaseObserver()
DNSManager.shared.loadProfile { _ in }

return true
Expand Down Expand Up @@ -402,3 +393,49 @@ extension AppDelegate: UIApplicationDelegate {
}

}

// MARK: - PurchaseManagerDelegate -

extension AppDelegate: PurchaseManagerDelegate {

func purchaseStart() {

}

func purchasePending() {
DispatchQueue.main.async {
guard let viewController = UIApplication.topViewController() else {
return
}

viewController.showAlert(title: "Pending payment", message: "Payment is pending for approval. We will complete the transaction as soon as payment is approved.")
}
}

func purchaseSuccess(activeUntil: String, extended: Bool) {
guard extended else {
return
}

DispatchQueue.main.async {
guard let viewController = UIApplication.topViewController() else {
return
}

viewController.showSubscriptionActivatedAlert(activeUntil: activeUntil)
}
}

func purchaseError(error: Any?) {
DispatchQueue.main.async {
guard let viewController = UIApplication.topViewController() else {
return
}

if let error = error as? ErrorResult {
viewController.showErrorAlert(title: "Error", message: error.message)
}
}
}

}
12 changes: 8 additions & 4 deletions IVPNClient/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ struct Config {
static let apiSessionDelete = "/v4/session/delete"
static let apiSessionWGKeySet = "/v4/session/wg/set"
static let apiAccountNew = "/v4/account/new"
static let apiPaymentInitial = "/v4/account/payment/ios/initial"
static let apiPaymentAdd = "/v4/account/payment/ios/add"
static let apiPaymentAddLegacy = "/v2/mobile/ios/subscription-purchased"
static let apiPaymentRestore = "/v4/account/payment/ios/restore"
static let apiPaymentInitial = "/v5/account/payment/ios/initial"
static let apiPaymentAdd = "/v5/account/payment/ios/add"
static let apiPaymentRestore = "/v5/account/payment/ios/restore"
static let apiPaymentAddLegacy = "/v2/mobile/ios/subscription-purchased-v2"

static let urlTypeLogin = "login"
static let urlTypeConnect = "connect"
Expand Down Expand Up @@ -109,4 +109,8 @@ struct Config {
return value
}

// MARK: Log files

static let maxBytes = 100000

}
1 change: 1 addition & 0 deletions IVPNClient/Enums/ApiResults/SessionStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Foundation
struct SessionStatus: Decodable {
let status: Int
let deviceName: String?
let extended: Bool?
let serviceStatus: ServiceStatus

var serviceActive: Bool {
Expand Down
Loading

0 comments on commit b8420ba

Please sign in to comment.