调试通畅firebaseremoteconfig

This commit is contained in:
bluesea 2024-04-12 15:09:22 +08:00
parent 90fec41d2d
commit 70f2e078ff
3 changed files with 40 additions and 20 deletions

View File

@ -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 = "<group>"; };
003624652BA3F0AB0080D014 /* ZZHImageExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHImageExtension.swift; sourceTree = "<group>"; };
005580772B9F1525004B9567 /* ZZHHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZZHHelper.swift; sourceTree = "<group>"; };
006B61C62BBA499D003FCB49 /* SKUPay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SKUPay.swift; sourceTree = "<group>"; };
@ -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 */,

View File

@ -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) {

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>menuParams</key>
<string>{"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"}]}}</string>
</dict>
</plist>