refactor: Rename some constants
This commit is contained in:
@@ -78,9 +78,9 @@
|
||||
[[EQNManager defaultManager] avviaManager];
|
||||
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
|
||||
|
||||
NSUInteger counter = [[NSUserDefaults standardUserDefaults] integerForKey:CONTEGGIO_APERTURE_PER_SCONTO];
|
||||
NSUInteger counter = [[NSUserDefaults standardUserDefaults] integerForKey:EQNUserDefaultProDiscountOpenCounter];
|
||||
counter += 1;
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:counter forKey:CONTEGGIO_APERTURE_PER_SCONTO];
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:counter forKey:EQNUserDefaultProDiscountOpenCounter];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)refreshUI;
|
||||
|
||||
/// Handle `IAPHelperPurchaseNotification` notification
|
||||
/// Handle `EQNNotificationDidCompleteInAppPurchase` notification
|
||||
/// @param notification Notification fired
|
||||
- (void)didReceiveInAppNotification:(NSNotification *)notification;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didReceiveInAppNotification:)
|
||||
name:IAPHelperPurchaseNotification object:nil];
|
||||
name:EQNNotificationDidCompleteInAppPurchase object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didReceiveDownloadCompleteNotification:)
|
||||
|
||||
@@ -35,7 +35,7 @@ class PurchaseProVersionViewController: UIViewController {
|
||||
super.viewDidLoad()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handlePurchaseNotification(_:)),
|
||||
name: .IAPHelperPurchaseNotification,
|
||||
name: .EQNNotificationDidCompleteInAppPurchase,
|
||||
object: nil)
|
||||
|
||||
configureUI()
|
||||
|
||||
@@ -36,7 +36,7 @@ class SubscriptionDetailViewController: UIViewController {
|
||||
super.viewDidLoad()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handlePurchaseNotification(_:)),
|
||||
name: .IAPHelperPurchaseNotification,
|
||||
name: .EQNNotificationDidCompleteInAppPurchase,
|
||||
object: nil)
|
||||
|
||||
updateUI()
|
||||
|
||||
@@ -73,11 +73,11 @@ class SubscriptionsViewController: UITableViewController {
|
||||
|
||||
private func addObservers() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handlePurchaseNotification(_:)),
|
||||
name: .IAPHelperPurchaseNotification,
|
||||
name: .EQNNotificationDidCompleteInAppPurchase,
|
||||
object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(fail(_:)),
|
||||
name: .IAPHelperPurchaseNotificationFail,
|
||||
name: .EQNNotificationDidCompleteInAppPurchaseFail,
|
||||
object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleNoTransactionsNotification(_:)),
|
||||
|
||||
@@ -67,6 +67,10 @@ static NSString * const EQNUserDefaultKeySesmicInformations = @"EQNetwork.Seismi
|
||||
static NSString * const EQNUserDefaultKeyOneShotShowCountry = @"EQNetwork.OneShot.CountrySelection";
|
||||
static NSString * const EQNUserDefaultLastLocation = @"EQNLast_Location";
|
||||
static NSString * const EQNUserDefaultSeismicNetworkCards = @"EQNData.RetiSismiche";
|
||||
/// Numero di aperture dell'app per sbloccare la versione Pro scontata
|
||||
static NSString * const EQNUserDefaultProDiscountOpenCounter = @"CONTEGGIO_APERTURE_PER_SCONTO";
|
||||
/// Prezzo scontato per la versione pro scaduto
|
||||
static NSString * const EQNUserDefaultProDiscountExpired = @"PREZZO_SCONTATO_SCADUTO";
|
||||
|
||||
#pragma mark - NSNotification
|
||||
|
||||
@@ -74,6 +78,8 @@ static NSString * const EQNUserDefaultSeismicNetworkCards = @"EQNData.RetiSismic
|
||||
static NSString * const EQNNotificationDidChangeAuthorizationStatus = @"EQNNotificationDidChangeAuthorizationStatus";
|
||||
/// Notifica di completamento download dei dati
|
||||
static NSString * const EQNNotificationDidDownloadData = @"EQNNotificationDidDownloadData";
|
||||
/// Notifica di acquisto in-app effettuato
|
||||
static NSString * const EQNNotificationDidCompleteInAppPurchase = @"EQNNotificationDidCompleteInAppPurchase";
|
||||
|
||||
#pragma mark - Other constants
|
||||
|
||||
@@ -236,11 +242,6 @@ typedef enum : NSInteger {
|
||||
#define EQN_ADMOB_ANNUNCIO_IDA @"ca-app-pub-0053870219990922/3394298808"
|
||||
#define EQN_ADMOB_ANNUNCIO_IDA_TEST @"ca-app-pub-3940256099942544/2934735716"
|
||||
|
||||
// ACQUISTI IN APP
|
||||
#define CONTEGGIO_APERTURE_PER_SCONTO @"CONTEGGIO_APERTURE_PER_SCONTO"
|
||||
#define PREZZO_SCONTATO_SCADUTO @"PREZZO_SCONTATO_SCADUTO"
|
||||
#define IAPHelperPurchaseNotification @"IAPHelperPurchaseNotification"
|
||||
|
||||
// FILTRO ENTI
|
||||
#define EQN_MAGNITUDO_MINIMA @"EQN_MAGNITUDO_MINIMA"
|
||||
#define EQN_DISTANZA_MASSIMA @"EQN_DISTANZA_MASSIMA"
|
||||
|
||||
@@ -20,13 +20,13 @@ public class EQNPurchaseUtility: NSObject {
|
||||
/// If zero, no discounted price is available
|
||||
/// - Parameter completion: Completion
|
||||
static func offerTimeRemaining(completion: @escaping (_ timeRemaining: Int) -> Void) {
|
||||
let appOpenCounter = UserDefaults.standard.integer(forKey:CONTEGGIO_APERTURE_PER_SCONTO)
|
||||
let appOpenCounter = UserDefaults.standard.integer(forKey:EQNUserDefaultProDiscountOpenCounter)
|
||||
if appOpenCounter < Self.AppOpenCountForDiscount {
|
||||
completion(0)
|
||||
return
|
||||
}
|
||||
|
||||
let discountExpired = UserDefaults.standard.bool(forKey: PREZZO_SCONTATO_SCADUTO)
|
||||
let discountExpired = UserDefaults.standard.bool(forKey: EQNUserDefaultProDiscountExpired)
|
||||
if discountExpired {
|
||||
completion(0)
|
||||
return
|
||||
@@ -34,7 +34,7 @@ public class EQNPurchaseUtility: NSObject {
|
||||
|
||||
EQNUser.default().downloadOfferTimeRemaining { (timeOffer) in
|
||||
if timeOffer == 0 {
|
||||
UserDefaults.standard.set(true, forKey: PREZZO_SCONTATO_SCADUTO)
|
||||
UserDefaults.standard.set(true, forKey: EQNUserDefaultProDiscountExpired)
|
||||
}
|
||||
|
||||
let timeInHours = timeOffer / 60
|
||||
@@ -90,13 +90,13 @@ public class EQNPurchaseUtility: NSObject {
|
||||
VersioneProProducts.Identifier.identifiers.forEach { (identifier) in
|
||||
UserDefaults.standard.removeObject(forKey: identifier)
|
||||
}
|
||||
NotificationCenter.default.post(name: .IAPHelperPurchaseNotification, object: nil)
|
||||
NotificationCenter.default.post(name: .EQNNotificationDidCompleteInAppPurchase, object: nil)
|
||||
}
|
||||
|
||||
/// Use to simulate the purchase of the Pro version
|
||||
@objc public static func simulateProPurchase(identifier: String) {
|
||||
// store and notify
|
||||
UserDefaults.standard.set(true, forKey: identifier)
|
||||
NotificationCenter.default.post(name: .IAPHelperPurchaseNotification, object: identifier)
|
||||
NotificationCenter.default.post(name: .EQNNotificationDidCompleteInAppPurchase, object: identifier)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public typealias ProductIdentifier = String
|
||||
public typealias ProductsRequestCompletionHandler = (_ success: Bool, _ products: [SKProduct]?) -> Void
|
||||
|
||||
extension Notification.Name {
|
||||
static let IAPHelperPurchaseNotification = Notification.Name("IAPHelperPurchaseNotification")
|
||||
static let IAPHelperPurchaseNotificationFail = Notification.Name("IAPHelperPurchaseNotificationFail")
|
||||
static let EQNNotificationDidCompleteInAppPurchase = Notification.Name("EQNNotificationDidCompleteInAppPurchase")
|
||||
static let EQNNotificationDidCompleteInAppPurchaseFail = Notification.Name("EQNNotificationDidCompleteInAppPurchaseFail")
|
||||
/// No available transactions to restore
|
||||
static let IAPHelperPurchaseNoTransactions = Notification.Name("IAPHelperPurchaseNoTransactions")
|
||||
|
||||
@@ -146,7 +146,7 @@ extension IAPHelper: SKPaymentTransactionObserver {
|
||||
|
||||
public func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) {
|
||||
print("[IAPHelper] Restore transaction failed (error : \(error.localizedDescription))")
|
||||
NotificationCenter.default.post(name: .IAPHelperPurchaseNotificationFail, object: nil)
|
||||
NotificationCenter.default.post(name: .EQNNotificationDidCompleteInAppPurchaseFail, object: nil)
|
||||
}
|
||||
|
||||
public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
|
||||
@@ -201,7 +201,7 @@ extension IAPHelper: SKPaymentTransactionObserver {
|
||||
print("[IAPHelper] Handle failed transaction error: \(localizedDescription)")
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(name: .IAPHelperPurchaseNotificationFail, object: nil)
|
||||
NotificationCenter.default.post(name: .EQNNotificationDidCompleteInAppPurchaseFail, object: nil)
|
||||
SKPaymentQueue.default().finishTransaction(transaction)
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ extension IAPHelper: SKPaymentTransactionObserver {
|
||||
|
||||
purchasedProductIdentifiers.insert(identifier)
|
||||
UserDefaults.standard.set(true, forKey: identifier)
|
||||
NotificationCenter.default.post(name: .IAPHelperPurchaseNotification, object: identifier)
|
||||
NotificationCenter.default.post(name: .EQNNotificationDidCompleteInAppPurchase, object: identifier)
|
||||
}
|
||||
|
||||
private func serverPurchaseRegistration(for productId: String, transactionId: String?) {
|
||||
|
||||
Reference in New Issue
Block a user