Skip to content

Commit ff278bb

Browse files
feat: Update getRMCSDKsVersion function to fetch all the sdk's versions from RmcInfo.plist (RMCCX-9281)
feat: Update getRMCSDKsVersion function to fetch all the sdk's versions from RmcInfo.plist (RMCCX-9281)
2 parents 73792aa + a9847af commit ff278bb

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

Sources/REventLogger/REventLoggerEnvironment.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,26 @@ final class REventLoggerEnvironment {
6161
}
6262

6363
private func getRMCSDKsVersion() -> [String: String]? {
64-
guard let path = Bundle.rmcBundle?.path(forResource: BundleKeys.rmcVersionsInfoList, ofType: "plist") else { return nil }
65-
return NSDictionary(contentsOfFile: path) as? [String: String]
64+
guard let path = Bundle.rmcBundle?.path(forResource: BundleKeys.rmcVersionsInfoList, ofType: "plist") else {
65+
return nil
66+
}
67+
let url = URL(fileURLWithPath: path)
68+
do {
69+
let data = try Data(contentsOf: url)
70+
let decoder = PropertyListDecoder()
71+
let versions = try decoder.decode(RMCSDKVersions.self, from: data)
72+
73+
let stringDictionary: [String: String] = [
74+
"rmcSdkVersion": versions.rmcSdkVersion,
75+
"rmcInAppMessagingSdkVersion": versions.rmcInAppMessagingSdkVersion,
76+
"rmcAppblocksSdkVersion": versions.rmcAppblocksSdkVersion,
77+
"rmcPushSdkVersion": versions.rmcPushSdkVersion
78+
]
79+
return stringDictionary
80+
} catch {
81+
Logger.debug("❌ Error decoding RmcInfo.plist: \(error)")
82+
return nil
83+
}
6684
}
6785
}
6886

Sources/REventLogger/RmcInfo.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
struct RMCSDKVersions: Decodable {
2+
let rmcSdkVersion: String
3+
let rmcInAppMessagingSdkVersion: String
4+
let rmcAppblocksSdkVersion: String
5+
let rmcPushSdkVersion: String
6+
}

0 commit comments

Comments
 (0)