From eb6ebaf5af785f1dc5c44e54e351bd8e1b1488ca Mon Sep 17 00:00:00 2001 From: reuk Date: Sun, 27 Oct 2024 18:05:04 +0000 Subject: [PATCH] Windowing: Fix deprecation warnings for iOS 17 --- modules/juce_gui_basics/juce_gui_basics.cpp | 5 +---- .../native/juce_Windowing_ios.mm | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/juce_gui_basics.cpp b/modules/juce_gui_basics/juce_gui_basics.cpp index 834455c16afe..929bea928827 100644 --- a/modules/juce_gui_basics/juce_gui_basics.cpp +++ b/modules/juce_gui_basics/juce_gui_basics.cpp @@ -75,10 +75,7 @@ #endif #elif JUCE_IOS - #if JUCE_PUSH_NOTIFICATIONS - #import - #endif - + #import #import #import #import diff --git a/modules/juce_gui_basics/native/juce_Windowing_ios.mm b/modules/juce_gui_basics/native/juce_Windowing_ios.mm index f8932c87fb70..6b11be9d91d7 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_ios.mm +++ b/modules/juce_gui_basics/native/juce_Windowing_ios.mm @@ -168,10 +168,27 @@ - (void) applicationWillEnterForeground: (UIApplication*) application app->resumed(); } -- (void) applicationDidBecomeActive: (UIApplication*) application +struct BadgeUpdateTrait { - application.applicationIconBadgeNumber = 0; + #if defined (__IPHONE_16_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 + API_AVAILABLE (ios (16)) + static void newFn (UIApplication*) + { + [[UNUserNotificationCenter currentNotificationCenter] setBadgeCount: 0 withCompletionHandler: nil]; + } + #endif + + static void oldFn (UIApplication* app) + { + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") + app.applicationIconBadgeNumber = 0; + JUCE_END_IGNORE_WARNINGS_GCC_LIKE + } +}; +- (void) applicationDidBecomeActive: (UIApplication*) application +{ + ifelse_17_0 (application); isIOSAppActive = true; }