Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calling setLaunchUrlsInApp after init #1043

Merged
merged 1 commit into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ + (void)setLaunchURLsInApp:(BOOL)launchInApp {
NSMutableDictionary *newSettings = [[NSMutableDictionary alloc] initWithDictionary:appSettings];
newSettings[kOSSettingsKeyInAppLaunchURL] = launchInApp ? @true : @false;
appSettings = newSettings;
// This allows this method to have an effect after init is called
[self enableInAppLaunchURL:launchInApp];
}

+ (void)setProvidesNotificationSettingsView:(BOOL)providesView {
Expand Down
16 changes: 16 additions & 0 deletions iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,22 @@ - (void)testLaunchURL {
XCTAssertFalse(OneSignalOverrider.launchWebURLWasCalled);
}

- (void)testsetLaunchURLInAppAfterInit {
// 1. setLaunchURLsInApp to false
[OneSignal setLaunchURLsInApp:false];

// 2. Init OneSignal with app start
[UnitTestCommonMethods initOneSignal];
[UnitTestCommonMethods runBackgroundThreads];

XCTAssertFalse([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]);

// 3. Change setLaunchURLsInApp to true
[OneSignal setLaunchURLsInApp:true];

XCTAssertTrue([OneSignalUserDefaults.initStandard getSavedBoolForKey:OSUD_NOTIFICATION_OPEN_LAUNCH_URL defaultValue:false]);
}

- (void)testTimezoneId {

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