Skip to content

Commit 4d1d9cd

Browse files
authored
Add support for sending CFBundleVersion along with the CFBundleShortV… (#5452)
* Add support for sending CFBundleVersion along with the CFBundleShortVersionString. * Style fixes.
1 parent 061d2c4 commit 4d1d9cd

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

FirebaseRemoteConfig/Sources/RCNConfigSettings.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ - (NSString *)nextRequestWithUserProperties:(NSDictionary *)userProperties {
352352
_bundleIdentifier]];
353353
ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_version:'%@'",
354354
FIRRemoteConfigAppVersion()]];
355+
ret = [ret stringByAppendingString:[NSString stringWithFormat:@", app_build:'%@'",
356+
FIRRemoteConfigAppBuildVersion()]];
355357
ret = [ret stringByAppendingString:[NSString stringWithFormat:@", sdk_version:'%d'",
356358
FIRRemoteConfigSDKVersion()]];
357359

FirebaseRemoteConfig/Sources/RCNDevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ NSString *FIRRemoteConfigPodVersion(void);
3232
/// App version.
3333
NSString *FIRRemoteConfigAppVersion(void);
3434

35+
/// App build version
36+
NSString *FIRRemoteConfigAppBuildVersion(void);
37+
3538
/// Device country, in lowercase.
3639
NSString *FIRRemoteConfigDeviceCountry(void);
3740

FirebaseRemoteConfig/Sources/RCNDevice.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@
2626
#define STR_EXPAND(x) #x
2727

2828
static NSString *const RCNDeviceContextKeyVersion = @"app_version";
29+
static NSString *const RCNDeviceContextKeyBuild = @"app_build";
2930
static NSString *const RCNDeviceContextKeyOSVersion = @"os_version";
3031
static NSString *const RCNDeviceContextKeyDeviceLocale = @"device_locale";
3132
static NSString *const RCNDeviceContextKeyLocaleLanguage = @"locale_language";
3233
static NSString *const RCNDeviceContextKeyGMPProjectIdentifier = @"GMP_project_Identifier";
3334

3435
NSString *FIRRemoteConfigAppVersion() {
36+
return [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];
37+
}
38+
39+
NSString *FIRRemoteConfigAppBuildVersion() {
3540
return [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"];
3641
}
3742

@@ -205,6 +210,7 @@ int FIRRemoteConfigSDKVersion() {
205210
NSString *GMPProjectIdentifier) {
206211
NSMutableDictionary *deviceContext = [[NSMutableDictionary alloc] init];
207212
deviceContext[RCNDeviceContextKeyVersion] = FIRRemoteConfigAppVersion();
213+
deviceContext[RCNDeviceContextKeyBuild] = FIRRemoteConfigAppBuildVersion();
208214
deviceContext[RCNDeviceContextKeyOSVersion] = [GULAppEnvironmentUtil systemVersion];
209215
deviceContext[RCNDeviceContextKeyDeviceLocale] = FIRRemoteConfigDeviceLocale();
210216
// NSDictionary setObjectForKey will fail if there's no GMP project ID, must check ahead.
@@ -219,6 +225,9 @@ BOOL FIRRemoteConfigHasDeviceContextChanged(NSDictionary *deviceContext,
219225
if (![deviceContext[RCNDeviceContextKeyVersion] isEqual:FIRRemoteConfigAppVersion()]) {
220226
return YES;
221227
}
228+
if (![deviceContext[RCNDeviceContextKeyBuild] isEqual:FIRRemoteConfigAppBuildVersion()]) {
229+
return YES;
230+
}
222231
if (!
223232
[deviceContext[RCNDeviceContextKeyOSVersion] isEqual:[GULAppEnvironmentUtil systemVersion]]) {
224233
return YES;

FirebaseRemoteConfig/Tests/Unit/RCNConfigDBManagerTest.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ - (void)testWriteAndLoadMetadataResult {
193193
NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier;
194194
NSTimeInterval lastFetchTimestamp = [NSDate date].timeIntervalSince1970;
195195

196-
NSDictionary *deviceContext = @{@"app_version" : @"1.0.1", @"os_version" : @"iOS9.1"};
196+
NSDictionary *deviceContext =
197+
@{@"app_version" : @"1.0.1", @"app_build" : @"1.0.1.11", @"os_version" : @"iOS9.1"};
197198
NSDictionary *syncedDBCustomVariables = @{@"user_level" : @15, @"user_experiences" : @"2468"};
198199
NSArray *successFetchTimes = @[];
199200
NSTimeInterval now = [NSDate date].timeIntervalSince1970;

0 commit comments

Comments
 (0)