mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 09:23:50 +08:00
[iOS] disable logging to application console in production (#1310)
* feat: replace NSLog statements with DLog statements * Ignore me Testing CI trigger
This commit is contained in:
committed by
Michael Diarmid
parent
97f6998776
commit
a506d1e5b5
@@ -1,4 +1,4 @@
|
||||
# editorconfig.org
|
||||
# editorconfig
|
||||
root = true
|
||||
|
||||
[*]
|
||||
|
||||
@@ -9,7 +9,7 @@ RCT_EXPORT_MODULE(RNFirebase);
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSLog(@"Setting up RNFirebase instance");
|
||||
DLog(@"Setting up RNFirebase instance");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
#import <React/RCTEventEmitter.h>
|
||||
#import <Firebase.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
|
||||
#else
|
||||
#define DLog(...)
|
||||
#endif
|
||||
|
||||
@interface RNFirebaseUtil : NSObject
|
||||
|
||||
+ (FIRApp *)getApp:(NSString *)appDisplayName;
|
||||
|
||||
@@ -32,7 +32,7 @@ static NSString *const DEFAULT_APP_NAME = @"__FIRAPP_DEFAULT";
|
||||
[emitter sendEventWithName:name body:body];
|
||||
}
|
||||
} @catch (NSException *error) {
|
||||
NSLog(@"An error occurred in sendJSEvent: %@", [error debugDescription]);
|
||||
DLog(@"An error occurred in sendJSEvent: %@", [error debugDescription]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -478,7 +478,7 @@ RCT_EXPORT_METHOD(updateProfile:
|
||||
[changeRequest setValue:props[key] forKey:key];
|
||||
}
|
||||
} @catch (NSException *exception) {
|
||||
NSLog(@"Exception occurred while configuring: %@", exception);
|
||||
DLog(@"Exception occurred while configuring: %@", exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ RCT_EXPORT_METHOD(fetchSignInMethodsForEmail:
|
||||
} else if ([provider compare:@"oauth" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
|
||||
credential = [FIROAuthProvider credentialWithProviderID:@"oauth" IDToken:authToken accessToken:authTokenSecret];
|
||||
} else {
|
||||
NSLog(@"Provider not yet handled: %@", provider);
|
||||
DLog(@"Provider not yet handled: %@", provider);
|
||||
}
|
||||
|
||||
return credential;
|
||||
|
||||
@@ -72,7 +72,7 @@ RCT_EXPORT_METHOD(transactionTryCommit:(NSString *)appDisplayName
|
||||
});
|
||||
|
||||
if (!transactionState) {
|
||||
NSLog(@"tryCommitTransaction for unknown ID %@", transactionId);
|
||||
DLog(@"tryCommitTransaction for unknown ID %@", transactionId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
[self handleDatabaseEvent:eventType registration:registration dataSnapshot:snapshot previousChildName:previousChildName];
|
||||
};
|
||||
id errorBlock = ^(NSError *_Nonnull error) {
|
||||
NSLog(@"Error onDBEvent: %@", [error debugDescription]);
|
||||
DLog(@"Error onDBEvent: %@", [error debugDescription]);
|
||||
[self removeEventListener:eventRegistrationKey];
|
||||
[self handleDatabaseError:registration error:error];
|
||||
};
|
||||
@@ -56,7 +56,7 @@
|
||||
NSDictionary *data = [RNFirebaseDatabaseReference snapshotToDictionary:snapshot previousChildName:previousChildName];
|
||||
resolve(data);
|
||||
} withCancelBlock:^(NSError *_Nonnull error) {
|
||||
NSLog(@"Error onDBEventOnce: %@", [error debugDescription]);
|
||||
DLog(@"Error onDBEventOnce: %@", [error debugDescription]);
|
||||
[RNFirebaseDatabase handlePromise:resolve rejecter:reject databaseError:error];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ RCT_EXPORT_METHOD(transactionGetDocument:(NSString *)appDisplayName
|
||||
});
|
||||
|
||||
if (!transactionState) {
|
||||
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ RCT_EXPORT_METHOD(transactionDispose:(NSString *)appDisplayName
|
||||
});
|
||||
|
||||
if (!transactionState) {
|
||||
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ RCT_EXPORT_METHOD(transactionApplyBuffer:(NSString *)appDisplayName
|
||||
});
|
||||
|
||||
if (!transactionState) {
|
||||
NSLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
DLog(@"transactionGetDocument called for non-existant transactionId %@", transactionId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSLog(@"Setting up RNFirebaseInvites instance");
|
||||
DLog(@"Setting up RNFirebaseInvites instance");
|
||||
// Set static instance for use from AppDelegate
|
||||
theRNFirebaseInvites = self;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ RCT_EXPORT_METHOD(getInitialInvitation:(RCTPromiseResolveBlock)resolve rejecter:
|
||||
if (url) {
|
||||
[FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||
DLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||
reject(@"invites/initial-invitation-error", @"Failed to handle invitation", error);
|
||||
} else if (receivedInvite && receivedInvite.inviteId) {
|
||||
resolve(@{
|
||||
@@ -168,7 +168,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
- (BOOL)handleUrl:(NSURL *)url {
|
||||
return [FIRInvites handleUniversalLink:url completion:^(FIRReceivedInvite * _Nullable receivedInvite, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"Failed to handle invitation: %@", [error localizedDescription]);
|
||||
DLog(@"Failed to handle invitation: %@", [error localizedDescription]);
|
||||
} else if (receivedInvite && receivedInvite.inviteId) {
|
||||
[self sendJSEvent:self name:INVITES_INVITATION_RECEIVED body:@{
|
||||
@"deepLink": receivedInvite.deepLink,
|
||||
@@ -188,7 +188,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
} else if (!initialInvite) {
|
||||
initialInvite = body;
|
||||
} else {
|
||||
NSLog(@"Multiple invite events received before the JS invites module has been initialised");
|
||||
DLog(@"Multiple invite events received before the JS invites module has been initialised");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE();
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSLog(@"Setting up RNFirebaseLinks instance");
|
||||
DLog(@"Setting up RNFirebaseLinks instance");
|
||||
// Set static instance for use from AppDelegate
|
||||
theRNFirebaseLinks = self;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ continueUserActivity:(NSUserActivity *)userActivity
|
||||
NSURL* url = dynamicLink.url;
|
||||
[self sendJSEvent:self name:LINKS_LINK_RECEIVED body:url.absoluteString];
|
||||
} else {
|
||||
NSLog(@"Failed to handle universal link: %@", userActivity.webpageURL);
|
||||
DLog(@"Failed to handle universal link: %@", userActivity.webpageURL);
|
||||
}
|
||||
}];
|
||||
}
|
||||
@@ -89,12 +89,12 @@ RCT_EXPORT_METHOD(createDynamicLink:(NSDictionary *)linkData
|
||||
reject(@"links/failure", @"Failed to create Dynamic Link", nil);
|
||||
} else {
|
||||
NSString *longLink = dynamicLink.url.absoluteString;
|
||||
NSLog(@"created long dynamic link: %@", longLink);
|
||||
DLog(@"created long dynamic link: %@", longLink);
|
||||
resolve(longLink);
|
||||
}
|
||||
}
|
||||
@catch(NSException * e) {
|
||||
NSLog(@"create dynamic link failure %@", e);
|
||||
DLog(@"create dynamic link failure %@", e);
|
||||
reject(@"links/failure",[e reason], nil);
|
||||
}
|
||||
}
|
||||
@@ -116,17 +116,17 @@ RCT_EXPORT_METHOD(createShortDynamicLink:(NSDictionary *)linkData
|
||||
}
|
||||
[components shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"create short dynamic link failure %@", [error localizedDescription]);
|
||||
DLog(@"create short dynamic link failure %@", [error localizedDescription]);
|
||||
reject(@"links/failure", @"Failed to create Short Dynamic Link", error);
|
||||
} else {
|
||||
NSString *shortLink = shortURL.absoluteString;
|
||||
NSLog(@"created short dynamic link: %@", shortLink);
|
||||
DLog(@"created short dynamic link: %@", shortLink);
|
||||
resolve(shortLink);
|
||||
}
|
||||
}];
|
||||
}
|
||||
@catch(NSException * e) {
|
||||
NSLog(@"create short dynamic link failure %@", e);
|
||||
DLog(@"create short dynamic link failure %@", e);
|
||||
reject(@"links/failure",[e reason], nil);
|
||||
}
|
||||
}
|
||||
@@ -143,11 +143,11 @@ RCT_EXPORT_METHOD(getInitialLink:(RCTPromiseResolveBlock)resolve rejecter:(RCTPr
|
||||
BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
|
||||
completion:^(FIRDynamicLink * _Nullable dynamicLink, NSError * _Nullable error) {
|
||||
if (error != nil){
|
||||
NSLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||
DLog(@"Failed to handle universal link: %@", [error localizedDescription]);
|
||||
reject(@"links/failure", @"Failed to handle universal link", error);
|
||||
} else {
|
||||
NSString* urlString = dynamicLink ? dynamicLink.url.absoluteString : userActivity.webpageURL.absoluteString;
|
||||
NSLog(@"initial link is: %@", urlString);
|
||||
DLog(@"initial link is: %@", urlString);
|
||||
resolve(urlString);
|
||||
}
|
||||
}];
|
||||
@@ -174,7 +174,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
} else if (!initialLink) {
|
||||
initialLink = body;
|
||||
} else {
|
||||
NSLog(@"Multiple link events received before the JS links module has been initialised");
|
||||
DLog(@"Multiple link events received before the JS links module has been initialised");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
return components;
|
||||
}
|
||||
@catch(NSException * e) {
|
||||
NSLog(@"error while building componets from meta data %@", e);
|
||||
DLog(@"error while building componets from meta data %@", e);
|
||||
@throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSLog(@"Setting up RNFirebaseMessaging instance");
|
||||
DLog(@"Setting up RNFirebaseMessaging instance");
|
||||
[self configure];
|
||||
}
|
||||
return self;
|
||||
@@ -84,7 +84,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
// Listen for FCM tokens
|
||||
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
|
||||
NSLog(@"Received new FCM token: %@", fcmToken);
|
||||
DLog(@"Received new FCM token: %@", fcmToken);
|
||||
[self sendJSEvent:self name:MESSAGING_TOKEN_REFRESHED body:fcmToken];
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
}
|
||||
[pendingMessages addObject:body];
|
||||
} else {
|
||||
NSLog(@"Received unexpected message type");
|
||||
DLog(@"Received unexpected message type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ RCT_EXPORT_MODULE();
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSLog(@"Setting up RNFirebaseNotifications instance");
|
||||
DLog(@"Setting up RNFirebaseNotifications instance");
|
||||
[self initialise];
|
||||
}
|
||||
return self;
|
||||
@@ -403,7 +403,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
if ([name isEqualToString:NOTIFICATIONS_NOTIFICATION_OPENED] && !initialNotification) {
|
||||
initialNotification = body;
|
||||
} else if ([name isEqualToString:NOTIFICATIONS_NOTIFICATION_OPENED]) {
|
||||
NSLog(@"Multiple notification open events received before the JS Notifications module has been initialised");
|
||||
DLog(@"Multiple notification open events received before the JS Notifications module has been initialised");
|
||||
}
|
||||
// PRE-BRIDGE-EVENTS: Consider enabling this to allow events built up before the bridge is built to be sent to the JS side
|
||||
// [pendingEvents addObject:@{@"name":name, @"body":body}];
|
||||
@@ -525,7 +525,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
if (attachment) {
|
||||
[attachments addObject:attachment];
|
||||
} else {
|
||||
NSLog(@"Failed to create attachment: %@", error);
|
||||
DLog(@"Failed to create attachment: %@", error);
|
||||
}
|
||||
}
|
||||
content.attachments = attachments;
|
||||
@@ -713,7 +713,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
|| [k3 isEqualToString:@"title-loc-key"]) {
|
||||
// Ignore known keys
|
||||
} else {
|
||||
NSLog(@"Unknown alert key: %@", k2);
|
||||
DLog(@"Unknown alert key: %@", k2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -726,7 +726,7 @@ RCT_EXPORT_METHOD(jsInitialised:(RCTPromiseResolveBlock)resolve rejecter:(RCTPro
|
||||
} else if ([k2 isEqualToString:@"sound"]) {
|
||||
notification[@"sound"] = aps[k2];
|
||||
} else {
|
||||
NSLog(@"Unknown aps key: %@", k2);
|
||||
DLog(@"Unknown aps key: %@", k2);
|
||||
}
|
||||
}
|
||||
} else if ([k1 isEqualToString:@"gcm.message_id"]) {
|
||||
|
||||
Reference in New Issue
Block a user