diff --git a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj index 8bb8662..9744d70 100644 --- a/SwiftProject/SwiftProject.xcodeproj/project.pbxproj +++ b/SwiftProject/SwiftProject.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 00290D1F2BC9125700B5244E /* remote_config_defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 00290D1E2BC9125700B5244E /* remote_config_defaults.plist */; }; 003624662BA3F0AB0080D014 /* ZZHImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 003624652BA3F0AB0080D014 /* ZZHImageExtension.swift */; }; 005580782B9F1525004B9567 /* ZZHHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 005580772B9F1525004B9567 /* ZZHHelper.swift */; }; 006B61C72BBA499D003FCB49 /* SKUPay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006B61C62BBA499D003FCB49 /* SKUPay.swift */; }; @@ -112,6 +113,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 00290D1E2BC9125700B5244E /* remote_config_defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = remote_config_defaults.plist; sourceTree = ""; }; 003624652BA3F0AB0080D014 /* ZZHImageExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHImageExtension.swift; sourceTree = ""; }; 005580772B9F1525004B9567 /* ZZHHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHHelper.swift; sourceTree = ""; }; 006B61C62BBA499D003FCB49 /* SKUPay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SKUPay.swift; sourceTree = ""; }; @@ -479,6 +481,7 @@ AF2120932B4E7F1A00400B7F /* Main.storyboard */, AF2120962B4E7F1C00400B7F /* Assets.xcassets */, 00C665722BAA81F900C309C3 /* GoogleService-Info.plist */, + 00290D1E2BC9125700B5244E /* remote_config_defaults.plist */, AF2120982B4E7F1C00400B7F /* LaunchScreen.storyboard */, AF21209B2B4E7F1C00400B7F /* Info.plist */, 00EB2D012BA2D14700924D84 /* Localizable.strings */, @@ -694,6 +697,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 00290D1F2BC9125700B5244E /* remote_config_defaults.plist in Resources */, 00EB2D022BA2D15700924D84 /* Localizable.strings in Resources */, AF21209A2B4E7F1C00400B7F /* LaunchScreen.storyboard in Resources */, AF2120972B4E7F1C00400B7F /* Assets.xcassets in Resources */, diff --git a/SwiftProject/SwiftProject/AppDelegate.swift b/SwiftProject/SwiftProject/AppDelegate.swift index 228e2bd..73f598b 100644 --- a/SwiftProject/SwiftProject/AppDelegate.swift +++ b/SwiftProject/SwiftProject/AppDelegate.swift @@ -20,17 +20,18 @@ import Firebase import FirebaseCore import AVFoundation import FacebookCore +import FirebaseRemoteConfig @main class AppDelegate: UIResponder, UIApplicationDelegate { - + var remoteConfig:FirebaseRemoteConfig.RemoteConfig? var window: UIWindow? // var root:RootManager? var newWindow:UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - FirebaseApp.configure() + configureFireBase() do { try AVAudioSession.sharedInstance().setActive(true) @@ -42,31 +43,38 @@ class AppDelegate: UIResponder, UIApplicationDelegate { SVProgressHUD.setDefaultStyle(.dark) - -// self.window = UIWindow(frame: UIScreen.main.bounds) -// self.window?.backgroundColor = UIColor.white -// self.window?.makeKeyAndVisible() - Analytics.logEvent("user_launch", parameters: ["type":"new"]) SKUPay.sharedInstance.requestProducts(productsIdentifiers: MemberShipModelItem.getProductsIDs()) SKUPay.sharedInstance.setUpUserInfo() return true } - -// func exceptionLogWithData() { -// CopyCrashHandler.setDefaultHandler() -// let str = CopyCrashHandler.getdataPath() -// let data = NSData.init(contentsOfFile: str) -// if data != nil { -// let crushStr:String? = String.init(data: data! as Data, encoding: String.Encoding.utf8) -// Analytics.logEvent("app_crash", parameters: ["crashInfo":crushStr ?? ""]) -// -// CopyCrashHandler.cleanCrashInfo() -// } -// -// } + func configureFireBase() { + FirebaseApp.configure() + remoteConfig = FirebaseRemoteConfig.RemoteConfig.remoteConfig() + let settings = RemoteConfigSettings() + settings.minimumFetchInterval = 0 + remoteConfig!.configSettings = settings + remoteConfig!.setDefaults(fromPlist: "remote_config_defaults") + + remoteConfig!.fetch {[weak self] (status, error) -> Void in + if status == .success { +// print("Config fetched!") + self?.remoteConfig?.activate { changed, error in +// print("Config fetched! e:\(error)") + } + } else { +// print("Config not fetched") +// print("Error: \(error?.localizedDescription ?? "No error available.")") + } + } + +// let zh = remoteConfig?.configValue(forKey: "menuParams") +// print("zh:\(zh)") + } + + //前后台切换--进入前台 func applicationWillEnterForeground(_ application: UIApplication) { diff --git a/SwiftProject/SwiftProject/remote_config_defaults.plist b/SwiftProject/SwiftProject/remote_config_defaults.plist new file mode 100644 index 0000000..0d7de2d --- /dev/null +++ b/SwiftProject/SwiftProject/remote_config_defaults.plist @@ -0,0 +1,8 @@ + + + + + menuParams + {"contactConfig":{"default":[{"icon":"xxxxxx","title":"wecht","url":""},{"icon":"xxxxxx","title":"wecht","url":""}],"zh":[{"icon":"xxxxxx","title":"wecht","url":"ffff"},{"icon":"xxxxxx","title":"wecht","url":"xxx"}]}} + + \ No newline at end of file