Skip to content

Commit 8e0e286

Browse files
authored
Merge pull request #898 from OneSignal/DisableOneSignalUsingInfoProcessToFixCrash
Give user the ability to disable onesignal load
2 parents a1598fc + 035c157 commit 8e0e286

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,11 @@ + (void)onSessionEnding:(NSArray<OSInfluence *> *)lastInfluences {
27152715
#pragma clang diagnostic ignored "-Wincomplete-implementation"
27162716
@implementation UIApplication (OneSignal)
27172717
+ (void)load {
2718+
2719+
if ([self shouldDisableBasedOnProcessArguments]) {
2720+
[OneSignal onesignal_Log:ONE_S_LL_WARN message:@"OneSignal method swizzling is disabled. Make sure the feature is enabled for production."];
2721+
return;
2722+
}
27182723
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"UIApplication(OneSignal) LOADED!"];
27192724

27202725
// Prevent Xcode storyboard rendering process from crashing with custom IBDesignable Views
@@ -2760,6 +2765,12 @@ +(void)setupUNUserNotificationCenterDelegate {
27602765
[OneSignalHelper registerAsUNNotificationCenterDelegate];
27612766
}
27622767

2768+
+(BOOL) shouldDisableBasedOnProcessArguments {
2769+
if ([NSProcessInfo.processInfo.arguments containsObject:@"DISABLE_ONESIGNAL_SWIZZLING"]) {
2770+
return YES;
2771+
}
2772+
return NO;
2773+
}
27632774
@end
27642775

27652776
#pragma clang diagnostic pop

0 commit comments

Comments
 (0)