Skip to content

Commit

Permalink
PushNotifications: Silence deprecation warnings
Browse files Browse the repository at this point in the history
The warnings are only silenced in code that is conditionally used on
older platforms. When the newer (non-deprecated) API is available, it
will be used.
  • Loading branch information
reuk committed Aug 4, 2022
1 parent 1346b14 commit 0d8a94a
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 74 deletions.
149 changes: 95 additions & 54 deletions modules/juce_gui_basics/native/juce_ios_Windowing.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,47 @@ - (void) application: (UIApplication*) application handleEventsForBackgroundURLS
completionHandler: (void (^)(void)) completionHandler;
- (void) applicationDidReceiveMemoryWarning: (UIApplication *) application;
#if JUCE_PUSH_NOTIFICATIONS
- (void) application: (UIApplication*) application didRegisterUserNotificationSettings: (UIUserNotificationSettings*) notificationSettings;
- (void) application: (UIApplication*) application didRegisterForRemoteNotificationsWithDeviceToken: (NSData*) deviceToken;
- (void) application: (UIApplication*) application didFailToRegisterForRemoteNotificationsWithError: (NSError*) error;
- (void) application: (UIApplication*) application didReceiveRemoteNotification: (NSDictionary*) userInfo;
- (void) application: (UIApplication*) application didReceiveRemoteNotification: (NSDictionary*) userInfo
fetchCompletionHandler: (void (^)(UIBackgroundFetchResult result)) completionHandler;
- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forRemoteNotification: (NSDictionary*) userInfo withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler;
- (void) application: (UIApplication*) application didReceiveLocalNotification: (UILocalNotification*) notification;
- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification completionHandler: (void(^)()) completionHandler;
- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler;
- (void) userNotificationCenter: (UNUserNotificationCenter*) center willPresentNotification: (UNNotification*) notification

- (void) application: (UIApplication*) application
didRegisterForRemoteNotificationsWithDeviceToken: (NSData*) deviceToken;
- (void) application: (UIApplication*) application
didFailToRegisterForRemoteNotificationsWithError: (NSError*) error;
- (void) application: (UIApplication*) application
didReceiveRemoteNotification: (NSDictionary*) userInfo;
- (void) application: (UIApplication*) application
didReceiveRemoteNotification: (NSDictionary*) userInfo
fetchCompletionHandler: (void (^)(UIBackgroundFetchResult result)) completionHandler;
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forRemoteNotification: (NSDictionary*) userInfo
withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler;

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")

- (void) application: (UIApplication*) application
didRegisterUserNotificationSettings: (UIUserNotificationSettings*) notificationSettings;
- (void) application: (UIApplication*) application
didReceiveLocalNotification: (UILocalNotification*) notification;
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification
completionHandler: (void(^)()) completionHandler;
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification
withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler;

JUCE_END_IGNORE_WARNINGS_GCC_LIKE

- (void) userNotificationCenter: (UNUserNotificationCenter*) center
willPresentNotification: (UNNotification*) notification
withCompletionHandler: (void (^)(UNNotificationPresentationOptions options)) completionHandler;
- (void) userNotificationCenter: (UNUserNotificationCenter*) center didReceiveNotificationResponse: (UNNotificationResponse*) response
- (void) userNotificationCenter: (UNUserNotificationCenter*) center
didReceiveNotificationResponse: (UNNotificationResponse*) response
withCompletionHandler: (void(^)())completionHandler;

#endif

@end
Expand Down Expand Up @@ -192,25 +214,9 @@ - (void) setPushNotificationsDelegateToUse: (NSObject*) delegate
}

#if JUCE_PUSH_NOTIFICATIONS
- (void) application: (UIApplication*) application didRegisterUserNotificationSettings: (UIUserNotificationSettings*) notificationSettings
{
ignoreUnused (application);

SEL selector = @selector (application:didRegisterUserNotificationSettings:);

if (_pushNotificationsDelegate != nil && [_pushNotificationsDelegate respondsToSelector: selector])
{
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: [_pushNotificationsDelegate methodSignatureForSelector: selector]];
[invocation setSelector: selector];
[invocation setTarget: _pushNotificationsDelegate];
[invocation setArgument: &application atIndex:2];
[invocation setArgument: &notificationSettings atIndex:3];

[invocation invoke];
}
}

- (void) application: (UIApplication*) application didRegisterForRemoteNotificationsWithDeviceToken: (NSData*) deviceToken
- (void) application: (UIApplication*) application
didRegisterForRemoteNotificationsWithDeviceToken: (NSData*) deviceToken
{
ignoreUnused (application);

Expand All @@ -228,7 +234,8 @@ - (void) application: (UIApplication*) application didRegisterForRemoteNotificat
}
}

- (void) application: (UIApplication*) application didFailToRegisterForRemoteNotificationsWithError: (NSError*) error
- (void) application: (UIApplication*) application
didFailToRegisterForRemoteNotificationsWithError: (NSError*) error
{
ignoreUnused (application);

Expand All @@ -246,7 +253,8 @@ - (void) application: (UIApplication*) application didFailToRegisterForRemoteNot
}
}

- (void) application: (UIApplication*) application didReceiveRemoteNotification: (NSDictionary*) userInfo
- (void) application: (UIApplication*) application
didReceiveRemoteNotification: (NSDictionary*) userInfo
{
ignoreUnused (application);

Expand All @@ -264,8 +272,9 @@ - (void) application: (UIApplication*) application didReceiveRemoteNotification:
}
}

- (void) application: (UIApplication*) application didReceiveRemoteNotification: (NSDictionary*) userInfo
fetchCompletionHandler: (void (^)(UIBackgroundFetchResult result)) completionHandler
- (void) application: (UIApplication*) application
didReceiveRemoteNotification: (NSDictionary*) userInfo
fetchCompletionHandler: (void (^)(UIBackgroundFetchResult result)) completionHandler
{
ignoreUnused (application);

Expand All @@ -284,9 +293,11 @@ - (void) application: (UIApplication*) application didReceiveRemoteNotification:
}
}

- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forRemoteNotification: (NSDictionary*) userInfo withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forRemoteNotification: (NSDictionary*) userInfo
withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler
{
ignoreUnused (application);

Expand All @@ -307,7 +318,29 @@ - (void) application: (UIApplication*) application handleActionWithIdentifier: (
}
}

- (void) application: (UIApplication*) application didReceiveLocalNotification: (UILocalNotification*) notification
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")

- (void) application: (UIApplication*) application
didRegisterUserNotificationSettings: (UIUserNotificationSettings*) notificationSettings
{
ignoreUnused (application);

SEL selector = @selector (application:didRegisterUserNotificationSettings:);

if (_pushNotificationsDelegate != nil && [_pushNotificationsDelegate respondsToSelector:selector])
{
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: [_pushNotificationsDelegate methodSignatureForSelector: selector]];
[invocation setSelector: selector];
[invocation setTarget: _pushNotificationsDelegate];
[invocation setArgument: &application atIndex: 2];
[invocation setArgument: &notificationSettings atIndex: 3];

[invocation invoke];
}
}

- (void) application: (UIApplication*) application
didReceiveLocalNotification: (UILocalNotification*) notification
{
ignoreUnused (application);

Expand All @@ -318,15 +351,17 @@ - (void) application: (UIApplication*) application didReceiveLocalNotification:
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: [_pushNotificationsDelegate methodSignatureForSelector: selector]];
[invocation setSelector: selector];
[invocation setTarget: _pushNotificationsDelegate];
[invocation setArgument: &application atIndex:2];
[invocation setArgument: &notification atIndex:3];
[invocation setArgument: &application atIndex: 2];
[invocation setArgument: &notification atIndex: 3];

[invocation invoke];
}
}

- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification completionHandler: (void(^)()) completionHandler
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification
completionHandler: (void(^)()) completionHandler
{
ignoreUnused (application);

Expand All @@ -346,9 +381,11 @@ - (void) application: (UIApplication*) application handleActionWithIdentifier: (
}
}

- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler
- (void) application: (UIApplication*) application
handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification
withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler
{
ignoreUnused (application);

Expand All @@ -369,8 +406,11 @@ - (void) application: (UIApplication*) application handleActionWithIdentifier: (
}
}

- (void) userNotificationCenter: (UNUserNotificationCenter*) center willPresentNotification: (UNNotification*) notification
withCompletionHandler: (void (^)(UNNotificationPresentationOptions options)) completionHandler
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

- (void) userNotificationCenter: (UNUserNotificationCenter*) center
willPresentNotification: (UNNotification*) notification
withCompletionHandler: (void (^)(UNNotificationPresentationOptions options)) completionHandler
{
ignoreUnused (center);

Expand All @@ -389,8 +429,9 @@ - (void) userNotificationCenter: (UNUserNotificationCenter*) center willPresentN
}
}

- (void) userNotificationCenter: (UNUserNotificationCenter*) center didReceiveNotificationResponse: (UNNotificationResponse*) response
withCompletionHandler: (void(^)()) completionHandler
- (void) userNotificationCenter: (UNUserNotificationCenter*) center
didReceiveNotificationResponse: (UNNotificationResponse*) response
withCompletionHandler: (void(^)()) completionHandler
{
ignoreUnused (center);

Expand Down
Loading

0 comments on commit 0d8a94a

Please sign in to comment.