Skip to content
Merged
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
24 changes: 24 additions & 0 deletions iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,30 @@ - (void)testNotificationPermissionsAcceptedBeforeAddingOneSiganl_waitsForAPNSTok
XCTAssertEqualObjects(OneSignalClientOverrider.lastHTTPRequest[@"identifier"], @"0000000000000000000000000000000000000000000000000000000000000000");
}

// We don't want wait for the developer to prompt for notifications, just register as as soon as we have an APNS token
- (void)testWaitsForAPNSTokenBeforePlayerCreate {
// 1. Set that notification permissions to unanwsered
UNUserNotificationCenterOverrider.authorizationStatus = [NSNumber numberWithInteger:UNAuthorizationStatusNotDetermined];

// 2. Setup delay of APNs reaponse
[UIApplicationOverrider setBlockApnsResponse:true];

// 3. Init OneSignal
[UnitTestCommonMethods initOneSignal_andThreadWait];
[NSObjectOverrider runPendingSelectors];

// 4. Don't make a network call right away
XCTAssertNil(OneSignalClientOverrider.lastHTTPRequest);

// 5. Simulate APNs now giving us a push token
[UIApplicationOverrider setBlockApnsResponse:false];
[UnitTestCommonMethods runBackgroundThreads];

// 6. Ensure we registered with push token and it has the correct notification_types
XCTAssertEqualObjects(OneSignalClientOverrider.lastHTTPRequest[@"notification_types"], @-18);
XCTAssertEqualObjects(OneSignalClientOverrider.lastHTTPRequest[@"identifier"], @"0000000000000000000000000000000000000000000000000000000000000000");
}

- (void)testNotificationTypesWhenAlreadyAcceptedWithAutoPromptOffOnFristStartPreIos10 {
OneSignalHelperOverrider.mockIOSVersion = 9;
[UnitTestCommonMethods setCurrentNotificationPermission:true];
Expand Down