@@ -739,6 +739,30 @@ - (void)testNotificationPermissionsAcceptedBeforeAddingOneSiganl_waitsForAPNSTok
739739 XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequest [@" identifier" ], @" 0000000000000000000000000000000000000000000000000000000000000000" );
740740}
741741
742+ // We don't want wait for the developer to prompt for notifications, just register as as soon as we have an APNS token
743+ - (void )testWaitsForAPNSTokenBeforePlayerCreate {
744+ // 1. Set that notification permissions to unanwsered
745+ UNUserNotificationCenterOverrider.authorizationStatus = [NSNumber numberWithInteger: UNAuthorizationStatusNotDetermined ];
746+
747+ // 2. Setup delay of APNs reaponse
748+ [UIApplicationOverrider setBlockApnsResponse: true ];
749+
750+ // 3. Init OneSignal
751+ [UnitTestCommonMethods initOneSignal_andThreadWait ];
752+ [NSObjectOverrider runPendingSelectors ];
753+
754+ // 4. Don't make a network call right away
755+ XCTAssertNil (OneSignalClientOverrider.lastHTTPRequest );
756+
757+ // 5. Simulate APNs now giving us a push token
758+ [UIApplicationOverrider setBlockApnsResponse: false ];
759+ [UnitTestCommonMethods runBackgroundThreads ];
760+
761+ // 6. Ensure we registered with push token and it has the correct notification_types
762+ XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequest [@" notification_types" ], @-18 );
763+ XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequest [@" identifier" ], @" 0000000000000000000000000000000000000000000000000000000000000000" );
764+ }
765+
742766- (void )testNotificationTypesWhenAlreadyAcceptedWithAutoPromptOffOnFristStartPreIos10 {
743767 OneSignalHelperOverrider.mockIOSVersion = 9 ;
744768 [UnitTestCommonMethods setCurrentNotificationPermission: true ];
0 commit comments