cca3c13d2d
Running this in a detached expo app can sometimes deadlock from thread issues. I've replaced `dispatch_sync(dispatch_get_main_queue(), ^{});` with `RCTUnsafeExecuteOnMainQueueSync(^{});` to fix this. I only hit the error in the `RNFirebaseStorage.m` but it seems like the `RNFirebaseAnalytics.m` and `RNFirebase.m` modules could also have this same issue. `RCTUnsafeExecuteOnMainQueueSync` checks to see if the method is being executed on the main thread before trying to sync to the main thread. If you try to sync on the main thread whilst on the main thread, you hit a deadlock. You can read more about it here: https://stackoverflow.com/questions/12379059/why-is-this-dispatch-sync-call-freezing?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa The only testing I did was in a seperate detached ExpoKit project. Running this function would cause the crash. ```js await firebase .storage() .ref(uploadUri) .putFile(uri); ```
42 lines
1.2 KiB
Objective-C
42 lines
1.2 KiB
Objective-C
#import "RNFirebaseAnalytics.h"
|
|
#import <React/RCTUtils.h>
|
|
|
|
#if __has_include(<FirebaseAnalytics/FIRAnalytics.h>)
|
|
#import <FirebaseAnalytics/FIRAnalytics.h>
|
|
#import <FirebaseCore/FIRAnalyticsConfiguration.h>
|
|
|
|
@implementation RNFirebaseAnalytics
|
|
RCT_EXPORT_MODULE();
|
|
|
|
RCT_EXPORT_METHOD(logEvent:(NSString *)name props:(NSDictionary *)props) {
|
|
[FIRAnalytics logEventWithName:name parameters:props];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(setAnalyticsCollectionEnabled:(BOOL) enabled) {
|
|
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:enabled];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(setCurrentScreen:(NSString *) screenName screenClass:(NSString *) screenClassOverriew) {
|
|
RCTUnsafeExecuteOnMainQueueSync(^{
|
|
[FIRAnalytics setScreenName:screenName screenClass:screenClassOverriew];
|
|
});
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(setUserId: (NSString *) id) {
|
|
[FIRAnalytics setUserID:id];
|
|
}
|
|
|
|
RCT_EXPORT_METHOD(setUserProperty: (NSString *) name value:(NSString *) value) {
|
|
[FIRAnalytics setUserPropertyString:value forName:name];
|
|
}
|
|
|
|
// not implemented on iOS sdk
|
|
RCT_EXPORT_METHOD(setMinimumSessionDuration:(nonnull NSNumber *) milliseconds) {}
|
|
RCT_EXPORT_METHOD(setSessionTimeoutDuration:(nonnull NSNumber *) milliseconds) {}
|
|
@end
|
|
|
|
#else
|
|
@implementation RNFirebaseAnalytics
|
|
@end
|
|
#endif
|