|
|
@@ -40,13 +40,13 @@
|
|
|
API_AVAILABLE(ios(10.0), macos(10.14), tvos(10.0)) {
|
|
|
}
|
|
|
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_OSX
|
|
|
+#if !TARGET_OS_TV
|
|
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
|
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
|
withCompletionHandler:(void (^)(void))completionHandler
|
|
|
API_AVAILABLE(macos(10.14), ios(10.0)) {
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_TV
|
|
|
|
|
|
@end
|
|
|
|
|
|
@@ -65,14 +65,14 @@
|
|
|
@end
|
|
|
@implementation FakeAppDelegate
|
|
|
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_TV
|
|
|
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION
|
|
|
- (void)application:(UIApplication *)application
|
|
|
didReceiveRemoteNotification:(NSDictionary *)userInfo
|
|
|
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
|
|
|
self.remoteNotificationWithFetchHandlerWasCalled = YES;
|
|
|
completionHandler(UIBackgroundFetchResultNewData);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION
|
|
|
|
|
|
- (void)application:(GULApplication *)application
|
|
|
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
|
@@ -106,14 +106,14 @@
|
|
|
API_AVAILABLE(ios(10.0), macos(10.14), tvos(10.0)) {
|
|
|
self.willPresentWasCalled = YES;
|
|
|
}
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_OSX
|
|
|
+#if !TARGET_OS_TV
|
|
|
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
|
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
|
withCompletionHandler:(void (^)(void))completionHandler
|
|
|
API_AVAILABLE(ios(10.0), macos(10.14)) {
|
|
|
self.didReceiveResponseWasCalled = YES;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_TV
|
|
|
@end
|
|
|
|
|
|
@interface GULAppDelegateSwizzler (FIRMessagingRemoteNotificationsProxyTest)
|
|
|
@@ -181,7 +181,7 @@
|
|
|
[invalidAppDelegate application:[GULAppDelegateSwizzler sharedApplication]
|
|
|
didReceiveRemoteNotification:@{}];
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_WATCH
|
|
|
|
|
|
#if !SWIFT_PACKAGE
|
|
|
// The next 3 tests depend on a sharedApplication which is not available in the Swift PM test env.
|
|
|
@@ -215,7 +215,7 @@
|
|
|
SEL remoteNotificationWithFetchHandler = @selector(application:
|
|
|
didReceiveRemoteNotification:fetchCompletionHandler:);
|
|
|
XCTAssertTrue([incompleteAppDelegate respondsToSelector:remoteNotificationWithFetchHandler]);
|
|
|
-#endif
|
|
|
+#endif // TARGET_OS_IOS || TARGET_OS_TV
|
|
|
|
|
|
SEL remoteNotification = @selector(application:didReceiveRemoteNotification:);
|
|
|
XCTAssertFalse([incompleteAppDelegate respondsToSelector:remoteNotification]);
|
|
|
@@ -243,7 +243,7 @@
|
|
|
XCTAssertTrue(appDelegate.remoteNotificationWithFetchHandlerWasCalled);
|
|
|
|
|
|
[self.mockMessaging verify];
|
|
|
-#endif
|
|
|
+#endif // TARGET_OS_IOS || TARGET_OS_TV
|
|
|
|
|
|
// Verify application:didRegisterForRemoteNotificationsWithDeviceToken:
|
|
|
NSData *deviceToken = [NSData data];
|
|
|
@@ -264,7 +264,7 @@
|
|
|
|
|
|
XCTAssertEqual(appDelegate.registerForRemoteNotificationsError, error);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !SWIFT_PACKAGE
|
|
|
|
|
|
- (void)testListeningForDelegateChangesOnInvalidUserNotificationCenter {
|
|
|
if (@available(macOS 10.14, iOS 10.0, *)) {
|
|
|
@@ -321,7 +321,7 @@
|
|
|
|
|
|
// Use an object that does actually implement the optional methods. Both should be called.
|
|
|
- (void)testSwizzledUserNotificationsCenterDelegate {
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_OSX
|
|
|
+#if !TARGET_OS_TV
|
|
|
FakeUserNotificationCenterDelegate *delegate = [[FakeUserNotificationCenterDelegate alloc] init];
|
|
|
OCMStub([self.mockUserNotificationCenter delegate]).andReturn(delegate);
|
|
|
[self.proxy swizzleMethodsIfPossible];
|
|
|
@@ -361,11 +361,11 @@
|
|
|
// Verify our swizzled method was called
|
|
|
[self.mockMessaging verify];
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_TV
|
|
|
}
|
|
|
|
|
|
- (id)userNotificationResponseWithMessage:(NSDictionary *)message {
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_OSX
|
|
|
+#if !TARGET_OS_TV
|
|
|
if (@available(macOS 10.14, iOS 10.0, *)) {
|
|
|
// Stub out: response.[mock notification above]
|
|
|
id mockNotificationResponse = OCMClassMock([UNNotificationResponse class]);
|
|
|
@@ -373,16 +373,16 @@
|
|
|
OCMStub([mockNotificationResponse notification]).andReturn(mockNotification);
|
|
|
return mockNotificationResponse;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_TV
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
- (UNNotification *)userNotificationWithMessage:(NSDictionary *)message
|
|
|
API_AVAILABLE(macos(10.14), ios(10.0)) {
|
|
|
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
|
|
|
-#if TARGET_OS_IOS || TARGET_OS_OSX
|
|
|
+#if !TARGET_OS_TV
|
|
|
content.userInfo = message;
|
|
|
-#endif
|
|
|
+#endif // !TARGET_OS_TV
|
|
|
id notificationRequest = OCMClassMock([UNNotificationRequest class]);
|
|
|
OCMStub([notificationRequest content]).andReturn(content);
|
|
|
id notification = OCMClassMock([UNNotification class]);
|