Skip to content

Commit a2d61de

Browse files
committed
Give user the ability to disable onesignal load
Users of one signal (including me) are experiencing crash in Simulator mode. This commit allows users the option to turn off oneSignal functionality by using NSProcessInfo arguments. To disable, use “DISABLE_ONESIGNAL_SWIZZLING” in “arguments passed on launch” in the scheme setup
1 parent e09d263 commit a2d61de

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
@@ -1595,6 +1595,11 @@ + (UNMutableNotificationContent*)serviceExtensionTimeWillExpireRequest:(UNNotifi
15951595
@implementation UIApplication (OneSignal)
15961596
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
15971597
+ (void)load {
1598+
1599+
if ([self shouldDisableBasedOnProcessArguments]) {
1600+
[OneSignal onesignal_Log:ONE_S_LL_WARN message:@"OneSignal method swizzling is disabled. Make sure the feature is enabled for production."];
1601+
return;
1602+
}
15981603
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"UIApplication(OneSignal) LOADED!"];
15991604

16001605
// Prevent Xcode storyboard rendering process from crashing with custom IBDesignable Views
@@ -1626,6 +1631,12 @@ + (void)load {
16261631
[OneSignalHelper registerAsUNNotificationCenterDelegate];
16271632
}
16281633

1634+
+(BOOL) shouldDisableBasedOnProcessArguments {
1635+
if ([NSProcessInfo.processInfo.arguments containsObject: @"DISABLE_ONESIGNAL_SWIZZLING"]) {
1636+
return YES;
1637+
}
1638+
return NO;
1639+
}
16291640
@end
16301641

16311642

0 commit comments

Comments
 (0)