From 510f40273208f629f43161c052d3aa334dad03e2 Mon Sep 17 00:00:00 2001 From: kcw-grunt Date: Mon, 6 May 2024 17:22:14 +0100 Subject: [PATCH] change Privacy manifest - Debugging the Transaction and the pusher - fixed conflict - revert partner data reference - updated tags - added push shutdown when user denied pushes - analytics note - bump version Signed-off-by: kcw-grunt --- PrivacyInfo.xcprivacy | 8 +---- litewallet.xcodeproj/project.pbxproj | 16 ++++----- litewallet/AppDelegate.swift | 36 +++++++++++++++---- litewallet/ApplicationController.swift | 6 ++-- litewallet/BundleExtension.swift | 12 +++++-- litewallet/Constants/Constants+Events.swift | 6 ++++ litewallet/PartnerData.swift | 32 +++++------------ .../ViewControllers/LoginViewController.swift | 1 - litewallet/WalletCoordinator.swift | 2 -- 9 files changed, 66 insertions(+), 53 deletions(-) diff --git a/PrivacyInfo.xcprivacy b/PrivacyInfo.xcprivacy index 3f3974adb..4b94fe8a5 100644 --- a/PrivacyInfo.xcprivacy +++ b/PrivacyInfo.xcprivacy @@ -4,10 +4,6 @@ NSPrivacyTracking - NSPrivacyTrackingDomains -NSPrivacyTrackingDomains - - NSPrivacyCollectedDataTypes @@ -93,13 +89,11 @@ NSPrivacyTrackingDomains - NSPrivacyTrackingDomains - NSPrivacyAccessedAPITypes NSPrivacyAccessedAPIType - + NSPrivacyAccessedAPICategoryUserDefaults NSPrivacyAccessedAPITypeReasons CA92.1 diff --git a/litewallet.xcodeproj/project.pbxproj b/litewallet.xcodeproj/project.pbxproj index c01f9a701..58016dba7 100644 --- a/litewallet.xcodeproj/project.pbxproj +++ b/litewallet.xcodeproj/project.pbxproj @@ -321,8 +321,8 @@ C3FDADED28B2DB090054FC80 /* SendAddressHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FDADEC28B2DB090054FC80 /* SendAddressHostingController.swift */; }; C3FF4D5F28AC5A5800713139 /* SendAddressCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FF4D5E28AC5A5800713139 /* SendAddressCellView.swift */; }; C3FF4D6128AC5AC100713139 /* SendAddressCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FF4D6028AC5AC100713139 /* SendAddressCellViewModel.swift */; }; - C738969F2BEA3C0200029095 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C738969E2BEA3C0200029095 /* GoogleService-Info.plist */; }; - C73896A12BEA3C4900029095 /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C73896A02BEA3C4900029095 /* partner-keys.plist */; }; + C738969F2BEA3C0200029095 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C738969E2BEA3C0200029095 /* GoogleService-Info.plist */; settings = {ASSET_TAGS = ("initial-resources", ); }; }; + C73896A12BEA3C4900029095 /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C73896A02BEA3C4900029095 /* partner-keys.plist */; settings = {ASSET_TAGS = ("initial-resources", ); }; }; CE03EC741EF256AC0038E3A8 /* SimpleUTXO.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE03EC731EF256AC0038E3A8 /* SimpleUTXO.swift */; }; CE0CD1591DBFBCF5004023DA /* ModalPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0CD1581DBFBCF5004023DA /* ModalPresenter.swift */; }; CE124CF81E67A8E500DFA146 /* TransactionDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE124CF71E67A8E500DFA146 /* TransactionDirection.swift */; }; @@ -4534,7 +4534,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240510.0; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; @@ -4550,7 +4550,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "-DDebug $(inherited)"; @@ -4891,7 +4891,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240510.0; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -4906,7 +4906,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "$(inherited)"; @@ -5032,7 +5032,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = litewallet/litewallet.entitlements; - CURRENT_PROJECT_VERSION = 240509.1; + CURRENT_PROJECT_VERSION = 240510.0; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ZV7987N2ZC; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = NO; @@ -5048,7 +5048,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.3; + MARKETING_VERSION = 3.13.4; ONLY_ACTIVE_ARCH = YES; ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "initial-resources speakTag"; OTHER_SWIFT_FLAGS = "-DDebug -DTestnet $(inherited)"; diff --git a/litewallet/AppDelegate.swift b/litewallet/AppDelegate.swift index 51656eab1..ada803597 100644 --- a/litewallet/AppDelegate.swift +++ b/litewallet/AppDelegate.swift @@ -14,6 +14,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { requestResourceWith(tag: ["initial-resources", "speakTag"]) { [self] in + + // Language + updateCurrentUserLocale(localeId: Locale.current.identifier) + Bundle.setLanguage(UserDefaults.selectedLanguage) + // Ops let startDate = Partner.partnerKeyPath(name: .litewalletStart) if startDate == "error-litewallet-start-key" { @@ -24,14 +29,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { self.setFirebaseConfiguration() // Pusher - self.pushNotifications.start(instanceId: Partner.partnerKeyPath(name: .pusherStaging)) - let generaliOSInterest = "general-ios" - let debugGeneraliOSInterest = "debug-general-ios" + self.pushNotifications.start(instanceId: Partner.partnerKeyPath(name: .pusher)) + let generalInterest = String.preferredLanguageInterest(currentId: UserDefaults.selectedLanguage) + let debugGeneralInterest = "debug-general" + + try? self.pushNotifications.clearDeviceInterests() try? self.pushNotifications - .addDeviceInterest(interest: generaliOSInterest) + .addDeviceInterest(interest: generalInterest) try? self.pushNotifications - .addDeviceInterest(interest: debugGeneraliOSInterest) + .addDeviceInterest(interest: debugGeneralInterest) let interests = self.pushNotifications.getDeviceInterests()?.joined(separator: "|") ?? "" let device = UIDevice.current.identifierForVendor?.uuidString ?? "ID" @@ -40,6 +47,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LWAnalytics.logEventWithParameters(itemName: ._20231202_RIGI, properties: interestsDict) + + let current = UNUserNotificationCenter.current() + + current.getNotificationSettings(completionHandler: { settings in + + debugPrint(settings.debugDescription) + if settings.authorizationStatus == .denied { + self.pushNotifications.clearAllState { + LWAnalytics.logEventWithParameters(itemName: ._20240506_DPN) + } + + self.pushNotifications.stop { + LWAnalytics.logEventWithParameters(itemName: ._20240510_SPN) + } + } + }) + } onFailure: { error in let properties: [String: String] = ["error_type": "on_demand_resources_not_found", @@ -58,8 +82,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { LWAnalytics.logEventWithParameters(itemName: ._20191105_AL) - Bundle.setLanguage(UserDefaults.selectedLanguage) - return true } diff --git a/litewallet/ApplicationController.swift b/litewallet/ApplicationController.swift index b47d2fb84..7e03eb85c 100644 --- a/litewallet/ApplicationController.swift +++ b/litewallet/ApplicationController.swift @@ -113,7 +113,7 @@ class ApplicationController: Subscriber, Trackable { } exchangeUpdater?.refresh(completion: {}) feeUpdater?.refresh() - walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } if modalPresenter?.walletManager == nil { modalPresenter?.walletManager = walletManager } @@ -127,7 +127,7 @@ class ApplicationController: Subscriber, Trackable { } exchangeUpdater?.refresh(completion: {}) feeUpdater?.refresh() - walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } if modalPresenter?.walletManager == nil { modalPresenter?.walletManager = walletManager } @@ -143,7 +143,7 @@ class ApplicationController: Subscriber, Trackable { if !store.state.isLoginRequired { UserDefaults.standard.set(Date().timeIntervalSince1970, forKey: timeSinceLastExitKey) } - walletManager?.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } + // walletManager?.apiClient?.kv?.syncAllKeys { print("KV finished syncing. err: \(String(describing: $0))") } } func performFetch(_ completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { diff --git a/litewallet/BundleExtension.swift b/litewallet/BundleExtension.swift index b45b085a3..7494709f5 100644 --- a/litewallet/BundleExtension.swift +++ b/litewallet/BundleExtension.swift @@ -22,8 +22,16 @@ public extension Bundle { object_setClass(Bundle.main, BundleEx.self as AnyClass) } - if let temp = language { - guard let bundle = Bundle(path: Bundle.main.path(forResource: temp, ofType: "lproj")!) else { + if var temp = language { + if temp == "zh" { + temp = "zh-Hans" + } + + guard let path = Bundle.main.path(forResource: temp, ofType: "lproj") else { + LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR) + return + } + guard let bundle = Bundle(path: path) else { LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR) return } diff --git a/litewallet/Constants/Constants+Events.swift b/litewallet/Constants/Constants+Events.swift index b2c8bc891..a0fc630e9 100644 --- a/litewallet/Constants/Constants+Events.swift +++ b/litewallet/Constants/Constants+Events.swift @@ -231,4 +231,10 @@ enum CustomEvent: String { /// Transactions info case _20240315_AI = "application_info" + + /// Disabled Push Notifications + case _20240506_DPN = "disabled_push_notifications" + + /// Stop Push Notifications + case _20240510_SPN = "stopped_push_notifications" } diff --git a/litewallet/PartnerData.swift b/litewallet/PartnerData.swift index 38d712e32..663b85ed4 100644 --- a/litewallet/PartnerData.swift +++ b/litewallet/PartnerData.swift @@ -6,7 +6,6 @@ enum PartnerName { case litewalletOps case litewalletStart case pusher - case pusherStaging } struct Partner { @@ -56,47 +55,34 @@ struct Partner { } case .litewalletOps: - return "ltc1qrk9t25v3s2r64knehcgdu9n4pwl2ccvf8z49fa" -// if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject], -// let opsArray = dictionary["litewallet-ops"] as? [String] -// { -// let randomInt = Int.random(in: 0 ..< opsArray.count) -// let key = opsArray[randomInt] -// return key -// } else { -// let errorDescription = "error_litewallet_opskey" -// LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription]) -// return errorDescription -// } - - case .litewalletStart: - if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject], - let key = dictionary["litewallet-start"] as? String + let opsArray = dictionary["litewallet-ops"] as? [String] { + let randomInt = Int.random(in: 0 ..< opsArray.count) + let key = opsArray[randomInt] return key } else { - let errorDescription = "error_litewallet_start_key" + let errorDescription = "error_litewallet_opskey" LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription]) return errorDescription } - case .pusher: + case .litewalletStart: if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject], - let key = dictionary["pusher-instance-id"] as? String + let key = dictionary["litewallet-start"] as? String { return key } else { - let errorDescription = "error_pusher_id_key" + let errorDescription = "error_litewallet_start_key" LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: ["error": errorDescription]) return errorDescription } - case .pusherStaging: + case .pusher: if let dictionary = NSDictionary(contentsOfFile: filePath) as? [String: AnyObject], - let key = dictionary["pusher-staging-instance-id"] as? String + let key = dictionary["pusher-instance-id"] as? String { return key } else { diff --git a/litewallet/ViewControllers/LoginViewController.swift b/litewallet/ViewControllers/LoginViewController.swift index dab0bcede..4e6fca6c1 100644 --- a/litewallet/ViewControllers/LoginViewController.swift +++ b/litewallet/ViewControllers/LoginViewController.swift @@ -428,7 +428,6 @@ class LoginViewController: UIViewController, Subscriber, Trackable { if let disabledUntil = walletManager?.walletDisabledUntil { let now = Date().timeIntervalSince1970 if disabledUntil > now { - saveEvent("login.locked") let disabledUntilDate = Date(timeIntervalSince1970: disabledUntil) let unlockInterval = disabledUntil - now let df = DateFormatter() diff --git a/litewallet/WalletCoordinator.swift b/litewallet/WalletCoordinator.swift index f44931efb..40199814e 100644 --- a/litewallet/WalletCoordinator.swift +++ b/litewallet/WalletCoordinator.swift @@ -158,8 +158,6 @@ class WalletCoordinator: Subscriber, Trackable { return transactions.compactMap { $0 }.sorted { $0.pointee.timestamp > $1.pointee.timestamp - }.compactMap { - Transaction($0, walletManager: walletManager, kvStore: kvStore, rate: rate) } .compactMap { Transaction($0, walletManager: walletManager, kvStore: kvStore, rate: rate)