mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
Add deprecations for renamed purchase methods so Xcode can suggest the rename. Update purchase methods for named completion block instead of _
64 lines
1.6 KiB
Swift
64 lines
1.6 KiB
Swift
//
|
|
// SplashScreenViewController.swift
|
|
// Magic Weather
|
|
//
|
|
// Created by Cody Kerns on 12/22/20.
|
|
//
|
|
|
|
import UIKit
|
|
import RevenueCat
|
|
|
|
/*
|
|
Use a splash screen to make sure we have access to PurchaserInfo before displaying a UI.
|
|
Configured in /Resources/UI/SplashScreen.storyboard
|
|
*/
|
|
|
|
class SplashScreenViewController: UIViewController {
|
|
|
|
@IBOutlet var errorLabel: UILabel!
|
|
@IBOutlet var retryButton: UIButton!
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
startAppForReal()
|
|
}
|
|
|
|
// - Since the splash screen is displayed first, this method attempts to start the app "for real"
|
|
func startAppForReal() {
|
|
Purchases.shared.getOfferings { (offerings, error) in
|
|
if let error = error {
|
|
self.catchError(error)
|
|
} else {
|
|
Purchases.shared.getCustomerInfo { (info, error) in
|
|
if let error = error {
|
|
self.catchError(error)
|
|
} else {
|
|
self.showMainView()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func catchError(_ error: Error) {
|
|
self.errorLabel.text = error.localizedDescription
|
|
self.retryButton.isHidden = false
|
|
}
|
|
|
|
@IBAction
|
|
func retryAfterError() {
|
|
self.errorLabel.text = nil
|
|
self.retryButton.isHidden = true
|
|
|
|
startAppForReal()
|
|
}
|
|
|
|
func showMainView() {
|
|
let main = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
|
|
main.modalPresentationStyle = .fullScreen
|
|
present(main, animated: true, completion: nil)
|
|
}
|
|
|
|
}
|