Skip to content

Commit 67804b8

Browse files
authored
[Sessions] Fix oneof specification for nanopb (#10459)
1 parent 11229b5 commit 67804b8

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ BOOL FIRSESIsPBStringEqual(pb_bytes_array_t* _Nullable pbString, NSString* _Null
6565
/// @param data NSData that's expected
6666
BOOL FIRSESIsPBDataEqual(pb_bytes_array_t* _Nullable pbArray, NSData* _Nullable data);
6767

68+
/// Returns the protobuf tag number. Use this to specify which oneof message type we are
69+
/// using for the platform\_info field. This function is required to be in Objective-C because
70+
/// Swift does not support c-style macros.
71+
pb_size_t FIRSESGetAppleApplicationInfoTag(void);
72+
6873
/// Returns the cellular mobile country code (mnc) if CoreTelephony is supported, otherwise nil
6974
NSString* _Nullable FIRSESNetworkMobileCountryCode(void);
7075

FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#import "FirebaseSessions/Sources/NanoPB/FIRSESNanoPBHelpers.h"
1919

20+
#import "FirebaseSessions/Protogen/nanopb/sessions.nanopb.h"
21+
2022
#import <nanopb/pb.h>
2123
#import <nanopb/pb_decode.h>
2224
#import <nanopb/pb_encode.h>
@@ -126,6 +128,10 @@ BOOL FIRSESIsPBDataEqual(pb_bytes_array_t *_Nullable pbArray, NSData *_Nullable
126128
return equal;
127129
}
128130

131+
pb_size_t FIRSESGetAppleApplicationInfoTag(void) {
132+
return firebase_appquality_sessions_ApplicationInfo_apple_app_info_tag;
133+
}
134+
129135
#ifdef TARGET_HAS_MOBILE_CONNECTIVITY
130136
CTTelephonyNetworkInfo *_Nullable FIRSESNetworkInfo(void) {
131137
static CTTelephonyNetworkInfo *networkInfo;

FirebaseSessions/Sources/SessionStartEvent.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class SessionStartEvent: NSObject, GDTCOREventDataObject {
3636
proto.session_data.previous_session_id = makeProtoStringOrNil(identifiers.previousSessionID)
3737
proto.session_data.event_timestamp_us = time.timestampUS
3838

39+
// `which_platform_info` tells nanopb which oneof we're choosing to fill in for our proto
40+
proto.application_info.which_platform_info = FIRSESGetAppleApplicationInfoTag()
3941
proto.application_info.app_id = makeProtoString(appInfo.appID)
4042
proto.application_info.session_sdk_version = makeProtoString(appInfo.sdkVersion)
4143
// proto.application_info.device_model = makeProtoString(appInfo.deviceModel)

0 commit comments

Comments
 (0)