Skip to content

Commit 149fb03

Browse files
authored
Merge pull request #1043 from OneSignal/fix/setLaunchUrlsInApp_after_init
Fix calling setLaunchUrlsInApp after init
2 parents 08df561 + 985e219 commit 149fb03

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ + (void)setLaunchURLsInApp:(BOOL)launchInApp {
698698
NSMutableDictionary *newSettings = [[NSMutableDictionary alloc] initWithDictionary:appSettings];
699699
newSettings[kOSSettingsKeyInAppLaunchURL] = launchInApp ? @true : @false;
700700
appSettings = newSettings;
701+
// This allows this method to have an effect after init is called
702+
[self enableInAppLaunchURL:launchInApp];
701703
}
702704

703705
+ (void)setProvidesNotificationSettingsView:(BOOL)providesView {

iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,6 +3318,22 @@ - (void)testLaunchURL {
33183318
XCTAssertFalse(OneSignalOverrider.launchWebURLWasCalled);
33193319
}
33203320

3321+
- (void)testsetLaunchURLInAppAfterInit {
3322+
// 1. setLaunchURLsInApp to false
3323+
[OneSignal setLaunchURLsInApp:false];
3324+
3325+
// 2. Init OneSignal with app start
3326+
[UnitTestCommonMethods initOneSignal];
3327+
[UnitTestCommonMethods runBackgroundThreads];
3328+
3329+
XCTAssertFalse([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]);
3330+
3331+
// 3. Change setLaunchURLsInApp to true
3332+
[OneSignal setLaunchURLsInApp:true];
3333+
3334+
XCTAssertTrue([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]);
3335+
}
3336+
33213337
- (void)testTimezoneId {
33223338

33233339
let mockTimezone = [NSTimeZone timeZoneWithName:@"Europe/London"];

0 commit comments

Comments
 (0)