From fbe7aeaed5116c753dbea506d847b8490fb42e5a Mon Sep 17 00:00:00 2001 From: InKwon James Kim Date: Tue, 16 Jul 2019 09:48:59 +0900 Subject: [PATCH] add expire date of pop-up notification --- GMERemittance/Info.plist | 2 +- .../User Interface/View/HomeViewController.swift | 8 ++++++++ .../User Interface/Wireframe/MainWireframe.swift | 1 + .../Wireframe/PopupNotificationWireframe.swift | 15 ++++++++++++--- GMERemittance/Utility/AppConstants.swift | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/GMERemittance/Info.plist b/GMERemittance/Info.plist index 6aaff02c..cf5a8b7d 100644 --- a/GMERemittance/Info.plist +++ b/GMERemittance/Info.plist @@ -30,7 +30,7 @@ CFBundleVersion - 0 + 1 Fabric APIKey diff --git a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift index 9870024d..6d09eaa2 100644 --- a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift +++ b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift @@ -807,6 +807,14 @@ extension HomeViewController { } private func popUpNotification() { + self.isShowTokenRenewAlert = true + + // FIXME: Temporary expire date + let dateformat = DateFormatter() + dateformat.dateFormat = "yyyy-MM-dd" + let expireDate = dateformat.date(from: "2019-08-01") + + UserDefaults.standard.set(expireDate, forKey: AppConstants.dateOfExpireNotification) PopupNotificationWireframe().show(source: self) } } diff --git a/GMERemittance/Module/Main/User Interface/Wireframe/MainWireframe.swift b/GMERemittance/Module/Main/User Interface/Wireframe/MainWireframe.swift index 81ee4f44..7272ab99 100644 --- a/GMERemittance/Module/Main/User Interface/Wireframe/MainWireframe.swift +++ b/GMERemittance/Module/Main/User Interface/Wireframe/MainWireframe.swift @@ -96,6 +96,7 @@ extension MainWireframe: MainWireframeInput { store.setValue(nil, forKey: UserKeys.accessCode) store.removeObject(forKey: AppConstants.dateOfDontShowNotification) + store.removeObject(forKey: AppConstants.dateOfExpireNotification) KeyChain.shared.save(data: "0", key: .login) diff --git a/GMERemittance/Module/PopupNotification/User Interface/Wireframe/PopupNotificationWireframe.swift b/GMERemittance/Module/PopupNotification/User Interface/Wireframe/PopupNotificationWireframe.swift index 5e109bb3..76a3fea6 100644 --- a/GMERemittance/Module/PopupNotification/User Interface/Wireframe/PopupNotificationWireframe.swift +++ b/GMERemittance/Module/PopupNotification/User Interface/Wireframe/PopupNotificationWireframe.swift @@ -33,12 +33,21 @@ extension PopupNotificationWireframe: PopupNotificationWireframeInput { } func show(source: UIViewController) { + let now = Date() + + // FIXME: Temporary expire date + if let expireDate = UserDefaults + .standard + .object(forKey: AppConstants.dateOfExpireNotification) as? Date { + if let remindDate = expireDate - now, remindDate <= 0 { + return + } + } + if let date = UserDefaults .standard .object(forKey: AppConstants.dateOfDontShowNotification) as? Date { - - let now = Date() - + // TODO: if now - date == 0 then don't show notification else show notification and delete dateOfDontShowNotification if let remindDate = now - date, remindDate == 0 { diff --git a/GMERemittance/Utility/AppConstants.swift b/GMERemittance/Utility/AppConstants.swift index dc28516f..6f32c368 100644 --- a/GMERemittance/Utility/AppConstants.swift +++ b/GMERemittance/Utility/AppConstants.swift @@ -34,6 +34,7 @@ class AppConstants { static let accessTokenRegTime = "accessTokenRegTime" static let accessTokenExpTime = "accessTokenExpTime" static let dateOfDontShowNotification = "dateOfDontShowNotification" + static let dateOfExpireNotification = "dateOfExpireNotification" } enum Devices {