Ver código fonte

【会员系统】补充dmg弹出AI领取逻辑

wangshuai 4 meses atrás
pai
commit
857bcd4d73
1 arquivos alterados com 30 adições e 0 exclusões
  1. 30 0
      PDF Office/PDF Master/AppDelegate.swift

+ 30 - 0
PDF Office/PDF Master/AppDelegate.swift

@@ -220,6 +220,36 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
         }
 
         NotificationCenter.default.addObserver(self, selector: #selector(deviceActivateStatusChangeNotification), name: NSNotification.Name(rawValue: "kDeviceActivateNotification"), object: nil)
+        
+        initDidFinish()
+    }
+    
+    func initDidFinish() {
+#if VERSION_DMG
+        let memberInfo: KMMemberInfo = KMMemberInfo.shared
+        if IAPProductsManager.default().isAvailableAllFunction() == false  &&  memberInfo.isLogin == false {
+                checkLoginAndPrompt()
+            }
+#endif
+        }
+    
+    func checkLoginAndPrompt() {
+        let lastPromptDateKey = "kUserfreehaveDMGAIlastPromptDate"
+        
+        let userDefaults = UserDefaults.standard
+        let lastPromptDate = userDefaults.object(forKey: lastPromptDateKey) as? Date
+        
+        if let lastDate = lastPromptDate {
+            // 如果距离上次提示超过7天,则再次提示
+            if Calendar.current.date(byAdding: .day, value: 7, to: lastDate)! <= Date() {
+                KMOpenDMGPopupBootWC.shared.showWindow(nil)
+                userDefaults.set(Date(), forKey: lastPromptDateKey) // 更新提示日期
+            }
+        } else {
+            // 如果没有记录,则显示提示
+            KMOpenDMGPopupBootWC.shared.showWindow(nil)
+            userDefaults.set(Date(), forKey: lastPromptDateKey) // 保存提示日期
+        }
     }
     
     func initiRateData() {