Skip to content

Commit

Permalink
fix(analytics): correct native types for extend_session parameter (#5973
Browse files Browse the repository at this point in the history
)

* fix(analytics,android): cast extend_session value to long

Firebase requires a long value in Android for the extend_session parameter. See https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param#public-static-final-string-extend_session

* fix(analytics,ios): cast extend_session value to @yES

Firebase in iOS expects an extend_session value of @yES. See https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Constants#/c:FIRParameterNames.h@kFIRParameterExtendSession
  • Loading branch information
phjudge authored Dec 31, 2021
1 parent 59cbe9f commit 23fdf61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ private Bundle toBundle(ReadableMap readableMap) {
((Bundle) item).putInt(FirebaseAnalytics.Param.QUANTITY, (int) number);
}
}
if (bundle.containsKey(FirebaseAnalytics.Param.EXTEND_SESSION)) {
double number = bundle.getDouble(FirebaseAnalytics.Param.EXTEND_SESSION);
bundle.putLong(FirebaseAnalytics.Param.EXTEND_SESSION, (long) number);
}
return bundle;
}
}
4 changes: 4 additions & 0 deletions packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ - (NSDictionary *)cleanJavascriptParams:(NSDictionary *)params {
}];
newParams[kFIRParameterItems] = [newItems copy];
}
NSNumber *extendSession = [newParams valueForKey:kFIRParameterExtendSession];
if ([extendSession isEqualToNumber:@1]) {
newParams[kFIRParameterExtendSession] = @YES;
}
return [newParams copy];
}

Expand Down

1 comment on commit 23fdf61

@vercel
Copy link

@vercel vercel bot commented on 23fdf61 Dec 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.