|
|
@@ -15,7 +15,7 @@ enum QSLGuideusersToCommentType : Int{
|
|
|
class QSLGuideusersToCommentManager: NSObject {
|
|
|
|
|
|
static let commentShare = QSLGuideusersToCommentManager()
|
|
|
-
|
|
|
+ var isClose = false
|
|
|
//归因渠道
|
|
|
public var clickCompanyChannel : String = ""
|
|
|
|
|
|
@@ -23,76 +23,47 @@ class QSLGuideusersToCommentManager: NSObject {
|
|
|
var commentType: QSLGuideusersToCommentType = .member
|
|
|
private var timer: Timer?
|
|
|
|
|
|
- // Initialize and setup notifications
|
|
|
+
|
|
|
+ var closeBtnClosure: (() -> ())?
|
|
|
+
|
|
|
override init() {
|
|
|
super.init()
|
|
|
setupAppStateNotifications()
|
|
|
- startTimer()
|
|
|
}
|
|
|
|
|
|
deinit {
|
|
|
- stopTimer()
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
}
|
|
|
|
|
|
// MARK: - Timer Management
|
|
|
|
|
|
private func setupAppStateNotifications() {
|
|
|
- NotificationCenter.default.addObserver(self,
|
|
|
- selector: #selector(appDidEnterBackground),
|
|
|
- name: UIApplication.didEnterBackgroundNotification,
|
|
|
- object: nil)
|
|
|
- NotificationCenter.default.addObserver(self,
|
|
|
- selector: #selector(appWillEnterForeground),
|
|
|
- name: UIApplication.willEnterForegroundNotification,
|
|
|
- object: nil)
|
|
|
- }
|
|
|
-
|
|
|
- @objc private func appWillEnterForeground() {
|
|
|
- startTimer()
|
|
|
- }
|
|
|
-
|
|
|
- @objc private func appDidEnterBackground() {
|
|
|
- stopTimer()
|
|
|
+ NotificationCenter.default.addObserver(
|
|
|
+ self,
|
|
|
+ selector: #selector(windowDidBecomeKey),
|
|
|
+ name: UIWindow.didBecomeKeyNotification,
|
|
|
+ object: nil)
|
|
|
}
|
|
|
-
|
|
|
- private func startTimer() {
|
|
|
- //print("startTimersfsdf---A--\(self.commentType)")
|
|
|
- // Invalidate existing timer if any
|
|
|
- stopTimer()
|
|
|
-
|
|
|
- // Create new timer that fires every minute
|
|
|
- timer = Timer.scheduledTimer(withTimeInterval: 60.0, repeats: true) { [weak self] _ in
|
|
|
- self?.timerFired()
|
|
|
+
|
|
|
+ @objc func windowDidBecomeKey(notification: Notification) {
|
|
|
+ if(self.isClose){
|
|
|
+ return
|
|
|
}
|
|
|
-
|
|
|
- // Fire immediately on first start
|
|
|
- timerFired()
|
|
|
- }
|
|
|
-
|
|
|
- private func stopTimer() {
|
|
|
- //print("startTimersfsdf---B--\(self.commentType)")
|
|
|
- timer?.invalidate()
|
|
|
- timer = nil
|
|
|
- }
|
|
|
-
|
|
|
- private func timerFired() {
|
|
|
- // Call your existing method here
|
|
|
-// manageWhetherTriggerPopUpWindow(commentType)
|
|
|
+ self.closeBtnClosure?()
|
|
|
}
|
|
|
|
|
|
// MARK: - Existing Methods (unchanged)
|
|
|
|
|
|
//管理处理是否触发好评引导弹窗
|
|
|
func manageWhetherTriggerPopUpWindow(_ showType: QSLGuideusersToCommentType, closeBtnClosure: @escaping () -> () = {}) {
|
|
|
- //print("startTimersfsdf---C--\(showType)---\(self.commentType)")
|
|
|
+ self.closeBtnClosure = closeBtnClosure
|
|
|
QSLNetwork().request(.guideIsTriggered(dict: [String: Any]())) { response in
|
|
|
let guideIsModel: QSLGuideIsTriggeredModel = response.mapObject(QSLGuideIsTriggeredModel.self, modelKey: "data")
|
|
|
self.commentType = showType
|
|
|
self.guideGobalModel = guideIsModel
|
|
|
if guideIsModel.trigger{
|
|
|
DispatchQueue.main.async {
|
|
|
- self.noMemberPositiveReviewPopWindow(closeBtnClosure: closeBtnClosure)
|
|
|
+ QSLInAppReviewmanager.requestReview()
|
|
|
}
|
|
|
}else{
|
|
|
closeBtnClosure()
|