Skip to content

Commit

Permalink
only allow when log level is debug or greater
Browse files Browse the repository at this point in the history
  • Loading branch information
casey-chow committed Aug 3, 2023
1 parent 8581ca1 commit cea67cd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
};

+ (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel;
+ (ONE_S_LOG_LEVEL)getLogLevel;
+ (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message;

@end
4 changes: 4 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ + (void)setLogLevel:(ONE_S_LOG_LEVEL)nsLogLevel {
_nsLogLevel = nsLogLevel;
}

+ (ONE_S_LOG_LEVEL)getLogLevel {
return nsLogLevel;
}

+ (void) onesignal_Log:(ONE_S_LOG_LEVEL)logLevel message:(NSString*) message {
onesignal_Log(logLevel, message);
}
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OSInAppMessageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ - (void)setupWebviewWithMessageHandler:(id<WKScriptMessageHandler>)handler {
self.webView.backgroundColor = [UIColor clearColor];
self.webView.opaque = NO;
// https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/
if (@available(macOS 13.3, iOS 16.4, *)) {
if (@available(macOS 13.3, iOS 16.4, *) && [OneSignalLog getLogLevel] >= ONE_S_LL_DEBUG) {
self.webView.inspectable = YES;
}
[self addSubview:self.webView];
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OneSignalWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (void)viewDidLoad {
_webView = [WKWebView new];
_webView.navigationDelegate = self;
// https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps/
if (@available(macOS 13.3, iOS 16.4, *)) {
if (@available(macOS 13.3, iOS 16.4, *) && [OneSignalLog getLogLevel] >= ONE_S_LL_DEBUG) {
_webView.inspectable = YES;
}
[self.view addSubview:_webView];
Expand Down

0 comments on commit cea67cd

Please sign in to comment.