From ab61f50f364f9fd819eee26051770cd3756ebf7b Mon Sep 17 00:00:00 2001 From: Wasin Thonkaew Date: Sat, 6 Jan 2018 10:17:19 +0800 Subject: [PATCH] Better manage internal settings. Add new api-key to Loggly. --- Potatso.xcodeproj/project.pbxproj | 4 ++++ Potatso/AppInitializer.swift | 2 +- Potatso/Info.plist | 2 ++ PotatsoBase/InfoInternal.swift | 26 ++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 PotatsoBase/InfoInternal.swift diff --git a/Potatso.xcodeproj/project.pbxproj b/Potatso.xcodeproj/project.pbxproj index a8e93c17..4676bb34 100644 --- a/Potatso.xcodeproj/project.pbxproj +++ b/Potatso.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 1ED659011E05C73100D4BEE3 /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ED659001E05C73100D4BEE3 /* CloudKit.framework */; }; 1ED659061E05E88C00D4BEE3 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ED659051E05E88C00D4BEE3 /* GameKit.framework */; }; 1ED66DEE1E05A72300638808 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ED66DED1E05A72300638808 /* StoreKit.framework */; }; + 1EE85E0C2000639700C5DB6C /* InfoInternal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE85E0B2000639700C5DB6C /* InfoInternal.swift */; }; 1EEBB8771FFFD4B500EB33C3 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EEBB8761FFFD4B500EB33C3 /* NetworkExtension.framework */; }; 1EEBB8781FFFD52700EB33C3 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EEBB8761FFFD4B500EB33C3 /* NetworkExtension.framework */; }; 1EEBB8791FFFD8A700EB33C3 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EEBB8761FFFD4B500EB33C3 /* NetworkExtension.framework */; }; @@ -345,6 +346,7 @@ 1ED659001E05C73100D4BEE3 /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; }; 1ED659051E05E88C00D4BEE3 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; 1ED66DED1E05A72300638808 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; + 1EE85E0B2000639700C5DB6C /* InfoInternal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoInternal.swift; sourceTree = ""; }; 1EEBB8761FFFD4B500EB33C3 /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; 1EF602941F113A660005E0C7 /* GeoLite2-Country.mmdb */ = {isa = PBXFileReference; lastKnownFileType = file; path = "GeoLite2-Country.mmdb"; sourceTree = ""; }; 217DDEB43D39CFD980088F46 /* Pods-PotatsoModel.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PotatsoModel.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PotatsoModel/Pods-PotatsoModel.debug.xcconfig"; sourceTree = ""; }; @@ -1294,6 +1296,7 @@ 9BC6002F1CB299DE00E5EA61 /* NSError+Helper.h */, 9BC600301CB299DE00E5EA61 /* NSError+Helper.m */, 9BC600211CB2921C00E5EA61 /* Info.plist */, + 1EE85E0B2000639700C5DB6C /* InfoInternal.swift */, ); path = PotatsoBase; sourceTree = ""; @@ -3176,6 +3179,7 @@ 9BC6002C1CB2922E00E5EA61 /* Potatso.m in Sources */, 9BC600341CB299DE00E5EA61 /* NSError+Helper.m in Sources */, B8F784681D3678B400F02FF5 /* Settings.m in Sources */, + 1EE85E0C2000639700C5DB6C /* InfoInternal.swift in Sources */, 9BC600321CB299DE00E5EA61 /* JSONUtils.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Potatso/AppInitializer.swift b/Potatso/AppInitializer.swift index 615d1f1d..4e90790e 100644 --- a/Potatso/AppInitializer.swift +++ b/Potatso/AppInitializer.swift @@ -37,7 +37,7 @@ class AppInitializer: NSObject, AppLifeCycleProtocol { DDLog.add(fileLogger) let logglyLogger = LogglyLogger() // Loggy Logger - logglyLogger.logglyKey = "io.wasin-secretkeyblabla" + logglyLogger.logglyKey = InfoInternal.shared.getLogglyAPIKey() let fields = LogglyFields() fields.userid = User.currentUser.id fields.appversion = AppEnv.fullVersion diff --git a/Potatso/Info.plist b/Potatso/Info.plist index 7b61b1af..bc726a0a 100644 --- a/Potatso/Info.plist +++ b/Potatso/Info.plist @@ -60,6 +60,8 @@ GroupIdentifier group.io.wasin.potatso + LogglyAPIKey + 488db635-457d-48f4-8818-ffcd489f588b UIBackgroundModes diff --git a/PotatsoBase/InfoInternal.swift b/PotatsoBase/InfoInternal.swift new file mode 100644 index 00000000..dc0a3217 --- /dev/null +++ b/PotatsoBase/InfoInternal.swift @@ -0,0 +1,26 @@ +// +// InfoInternal.swift +// PotatsoBase +// +// Created by Wasin Thonkaew on 1/6/18. +// Copyright © 2018 TouchingApp. All rights reserved. +// + +import Foundation + +public class InfoInternal: NSObject { + public static let shared = InfoInternal() + var infoDict: Dictionary + + fileprivate override init() { + infoDict = Bundle.main.infoDictionary!["PotatsoInternal"] as! Dictionary + } + + public func getGroupIdentifier() -> String { + return infoDict["GroupIdentifier"] as! String + } + + public func getLogglyAPIKey() -> String { + return infoDict["LogglyAPIKey"] as! String + } +}