1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

iOS: Remove iOS 10 preprocessor checks

The current minimum-supported Xcode (10.1) includes the iOS 12.1 SDK, so
APIs from iOS 10 will always be available.
This commit is contained in:
reuk 2022-07-19 13:53:58 +01:00
parent 3d82933904
commit f821015080
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
8 changed files with 6 additions and 96 deletions

View file

@ -293,10 +293,8 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
options |= (AVAudioSessionCategoryOptionDefaultToSpeaker
| AVAudioSessionCategoryOptionAllowBluetooth);
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if (@available (iOS 10.0, *))
options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP;
#endif
}
JUCE_NSERROR_CHECK ([[AVAudioSession sharedInstance] setCategory: category
@ -735,7 +733,6 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
&dataSize);
if (err == noErr)
{
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if (@available (iOS 10.0, *))
{
[[UIApplication sharedApplication] openURL: (NSURL*) hostUrl
@ -744,7 +741,6 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
return;
}
#endif
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
[[UIApplication sharedApplication] openURL: (NSURL*) hostUrl];

View file

@ -410,7 +410,6 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String&
#if JUCE_IOS
ignoreUnused (parameters);
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if (@available (iOS 10.0, *))
{
[[UIApplication sharedApplication] openURL: filenameAsURL
@ -419,7 +418,6 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String&
return true;
}
#endif
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
return [[UIApplication sharedApplication] openURL: filenameAsURL];

View file

@ -54,7 +54,7 @@
#import <MetalKit/MetalKit.h>
#elif JUCE_IOS
#if JUCE_PUSH_NOTIFICATIONS && defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#if JUCE_PUSH_NOTIFICATIONS
#import <UserNotifications/UserNotifications.h>
#endif

View file

@ -26,10 +26,6 @@
namespace juce
{
#if ! defined (__IPHONE_10_0) || __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_10_0
using UIActivityType = NSString*;
#endif
class ContentSharer::ContentSharerNativeImpl : public ContentSharer::Pimpl,
private Component
{

View file

@ -37,7 +37,7 @@ namespace juce
Array<AppInactivityCallback*> appBecomingInactiveCallbacks;
}
#if JUCE_PUSH_NOTIFICATIONS && defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#if JUCE_PUSH_NOTIFICATIONS
@interface JuceAppStartupDelegate : NSObject <UIApplicationDelegate, UNUserNotificationCenterDelegate>
#else
@interface JuceAppStartupDelegate : NSObject <UIApplicationDelegate>
@ -74,13 +74,11 @@ namespace juce
- (void) application: (UIApplication*) application handleActionWithIdentifier: (NSString*) identifier
forLocalNotification: (UILocalNotification*) notification withResponseInfo: (NSDictionary*) responseInfo
completionHandler: (void(^)()) completionHandler;
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
- (void) userNotificationCenter: (UNUserNotificationCenter*) center willPresentNotification: (UNNotification*) notification
withCompletionHandler: (void (^)(UNNotificationPresentationOptions options)) completionHandler;
- (void) userNotificationCenter: (UNUserNotificationCenter*) center didReceiveNotificationResponse: (UNNotificationResponse*) response
withCompletionHandler: (void(^)())completionHandler;
#endif
#endif
@end
@ -93,7 +91,7 @@ namespace juce
self = [super init];
appSuspendTask = UIBackgroundTaskInvalid;
#if JUCE_PUSH_NOTIFICATIONS && defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#if JUCE_PUSH_NOTIFICATIONS
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
#endif
@ -371,7 +369,6 @@ namespace juce
}
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
- (void) userNotificationCenter: (UNUserNotificationCenter*) center willPresentNotification: (UNNotification*) notification
withCompletionHandler: (void (^)(UNNotificationPresentationOptions options)) completionHandler
{
@ -412,7 +409,6 @@ namespace juce
}
}
#endif
#endif
@end

View file

@ -67,10 +67,7 @@
#import <WebKit/WebKit.h>
#if JUCE_PUSH_NOTIFICATIONS
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import <UserNotifications/UserNotifications.h>
#endif
#import <UserNotifications/UserNotifications.h>
#include "native/juce_ios_PushNotifications.cpp"
#endif

View file

@ -53,7 +53,6 @@ namespace PushNotificationsDelegateDetails
}
else
{
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if (a.style == Action::text)
{
return [UNTextInputNotificationAction actionWithIdentifier: juceStringToNS (a.identifier)
@ -66,9 +65,6 @@ namespace PushNotificationsDelegateDetails
return [UNNotificationAction actionWithIdentifier: juceStringToNS (a.identifier)
title: juceStringToNS (a.title)
options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2)];
#else
return nullptr;
#endif
}
}
@ -96,7 +92,6 @@ namespace PushNotificationsDelegateDetails
}
else
{
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
auto actions = [NSMutableArray arrayWithCapacity: (NSUInteger) c.actions.size()];
for (const auto& a : c.actions)
@ -109,9 +104,6 @@ namespace PushNotificationsDelegateDetails
actions: actions
intentIdentifiers: @[]
options: c.sendDismissAction ? UNNotificationCategoryOptionCustomDismissAction : 0];
#else
return nullptr;
#endif
}
}
@ -139,7 +131,6 @@ namespace PushNotificationsDelegateDetails
return notification;
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
UNNotificationRequest* juceNotificationToUNNotificationRequest (const PushNotifications::Notification& n)
{
// content
@ -183,7 +174,6 @@ namespace PushNotificationsDelegateDetails
return request;
}
#endif
String getUserResponseFromNSDictionary (NSDictionary* dictionary)
{
@ -232,7 +222,6 @@ namespace PushNotificationsDelegateDetails
}
//==============================================================================
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
double getIntervalSecFromUNNotificationTrigger (UNNotificationTrigger* t)
{
if (t != nil)
@ -287,7 +276,6 @@ namespace PushNotificationsDelegateDetails
{
return unNotificationRequestToJuceNotification (n.request);
}
#endif
PushNotifications::Notification uiLocalNotificationToJuceNotification (UILocalNotification* n)
{
@ -340,7 +328,6 @@ namespace PushNotificationsDelegateDetails
return category;
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
Action unNotificationActionToAction (UNNotificationAction* a)
{
Action action;
@ -378,7 +365,6 @@ namespace PushNotificationsDelegateDetails
return category;
}
#endif
PushNotifications::Notification nsDictionaryToJuceNotification (NSDictionary* dictionary)
{
@ -457,32 +443,20 @@ struct PushNotificationsDelegate
NSDictionary* responseInfo,
void (^completionHandler)()) = 0;
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
virtual void willPresentNotificationWithCompletionHandler (UNNotification* notification,
void (^completionHandler)(UNNotificationPresentationOptions options)) = 0;
virtual void didReceiveNotificationResponseWithCompletionHandler (UNNotificationResponse* response,
void (^completionHandler)()) = 0;
#endif
protected:
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
NSUniquePtr<NSObject<UIApplicationDelegate, UNUserNotificationCenterDelegate>> delegate;
#else
NSUniquePtr<NSObject<UIApplicationDelegate>> delegate;
#endif
private:
//==============================================================================
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
struct Class : public ObjCClass<NSObject<UIApplicationDelegate, UNUserNotificationCenterDelegate>>
{
Class() : ObjCClass<NSObject<UIApplicationDelegate, UNUserNotificationCenterDelegate>> ("JucePushNotificationsDelegate_")
#else
struct Class : public ObjCClass<NSObject<UIApplicationDelegate>>
{
Class() : ObjCClass<NSObject<UIApplicationDelegate>> ("JucePushNotificationsDelegate_")
#endif
{
addIvar<PushNotificationsDelegate*> ("self");
@ -531,7 +505,6 @@ private:
getThis (self). handleActionForLocalNotificationWithResponseCompletionHandler (actionIdentifier, notification, responseInfo, completionHandler);
});
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
addMethod (@selector (userNotificationCenter:willPresentNotification:withCompletionHandler:), [] (id self, SEL, UNUserNotificationCenter*, UNNotification* notification, void (^completionHandler)(UNNotificationPresentationOptions options))
{
getThis (self).willPresentNotificationWithCompletionHandler (notification, completionHandler);
@ -541,7 +514,6 @@ private:
{
getThis (self).didReceiveNotificationResponseWithCompletionHandler (response, completionHandler);
});
#endif
registerClass();
}
@ -599,7 +571,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
UIUserNotificationSettings* s = [UIUserNotificationSettings settingsForTypes: type categories: categories];
[[UIApplication sharedApplication] registerUserNotificationSettings: s];
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
for (const auto& c : settings.categories)
@ -619,7 +590,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
requestSettingsUsed();
}];
}
#endif
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
@ -639,7 +609,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); });
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
@ -662,7 +631,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
}];
}
#endif
}
bool areNotificationsEnabled() const { return true; }
@ -676,7 +644,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
[[UIApplication sharedApplication] scheduleLocalNotification: notification];
[notification release];
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
@ -691,7 +658,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
NSLog (nsStringLiteral ("addNotificationRequest error: %@"), error);
}];
}
#endif
}
void getDeliveredNotifications() const
@ -702,7 +668,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
jassertfalse;
owner.listeners.call ([] (Listener& l) { l.deliveredNotificationsListReceived ({}); });
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
[[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:
@ -716,7 +681,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifs); });
}];
}
#endif
}
void removeAllDeliveredNotifications()
@ -727,12 +691,9 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
jassertfalse;
}
else
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
{
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
}
#endif
}
void removeDeliveredNotification (const String& identifier)
@ -743,7 +704,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
// Not supported on this platform
jassertfalse;
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
@ -751,7 +711,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers: identifiers];
}
#endif
}
void setupChannels (const Array<ChannelGroup>& groups, const Array<Channel>& channels)
@ -770,7 +729,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); });
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
@ -786,7 +744,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
}
];
}
#endif
}
void removePendingLocalNotification (const String& identifier)
@ -796,15 +753,12 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
// Not supported on this platform
jassertfalse;
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
NSArray<NSString*>* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)];
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers: identifiers];
}
#endif
}
void removeAllPendingLocalNotifications()
@ -813,12 +767,10 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
else
{
[[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests];
}
#endif
}
String getDeviceToken()
@ -926,7 +878,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
completionHandler();
}
#if defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
void willPresentNotificationWithCompletionHandler (UNNotification* notification,
void (^completionHandler)(UNNotificationPresentationOptions options)) override
{
@ -964,7 +915,6 @@ struct PushNotifications::Pimpl : private PushNotificationsDelegate
owner.listeners.call ([&] (Listener& l) { l.handleNotificationAction (! remote, n, actionString, responseString); });
completionHandler();
}
#endif
void subscribeToTopic (const String& topic) { ignoreUnused (topic); }
void unsubscribeFromTopic (const String& topic) { ignoreUnused (topic); }

View file

@ -23,10 +23,7 @@
==============================================================================
*/
#if (defined (__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0)
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
#define JUCE_USE_NEW_CAMERA_API 1
#endif
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
struct CameraDevice::Pimpl
{
@ -141,7 +138,6 @@ struct CameraDevice::Pimpl
private:
static NSArray<AVCaptureDevice*>* getDevices()
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
std::unique_ptr<NSMutableArray<AVCaptureDeviceType>, NSObjectDeleter> deviceTypes ([[NSMutableArray alloc] initWithCapacity: 2]);
@ -161,7 +157,6 @@ private:
return [discoverySession devices];
}
#endif
return [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];
}
@ -207,13 +202,11 @@ private:
JUCE_CAMERA_LOG ("Supports custom exposure: " + String ((int)[device isExposureModeSupported: AVCaptureExposureModeCustom]));
JUCE_CAMERA_LOG ("Supports point of interest exposure: " + String ((int)device.exposurePointOfInterestSupported));
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
JUCE_CAMERA_LOG ("Device type: " + nsStringToJuce (device.deviceType));
JUCE_CAMERA_LOG ("Locking focus with custom lens position supported: " + String ((int)device.lockingFocusWithCustomLensPositionSupported));
}
#endif
#if defined (__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
if (@available (iOS 11.0, *))
@ -238,7 +231,6 @@ private:
{
JUCE_CAMERA_LOG ("Media type: " + nsStringToJuce (format.mediaType));
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
String colourSpaces;
@ -255,7 +247,6 @@ private:
JUCE_CAMERA_LOG ("Supported colour spaces: " + colourSpaces);
}
#endif
JUCE_CAMERA_LOG ("Video field of view: " + String (format.videoFieldOfView));
JUCE_CAMERA_LOG ("Video max zoom factor: " + String (format.videoMaxZoomFactor));
@ -592,14 +583,12 @@ private:
captureOutput (createCaptureOutput()),
photoOutputDelegate (nullptr)
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
static PhotoOutputDelegateClass cls;
photoOutputDelegate.reset ([cls.createInstance() init]);
PhotoOutputDelegateClass::setOwner (photoOutputDelegate.get(), this);
}
#endif
captureSession.addOutputIfPossible (captureOutput);
}
@ -619,7 +608,6 @@ private:
if (auto* connection = findVideoConnection (captureOutput))
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]])
@ -634,7 +622,6 @@ private:
return;
}
}
#endif
auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput;
auto outputConnection = [stillImageOutput connectionWithMediaType: AVMediaTypeVideo];
@ -671,17 +658,14 @@ private:
private:
static AVCaptureOutput* createCaptureOutput()
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
return [AVCapturePhotoOutput new];
#endif
return [AVCaptureStillImageOutput new];
}
static void printImageOutputDebugInfo (AVCaptureOutput* captureOutput)
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
{
if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]])
@ -737,7 +721,6 @@ private:
return;
}
}
#endif
auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput;
@ -765,7 +748,6 @@ private:
}
//==============================================================================
#if JUCE_USE_NEW_CAMERA_API
class API_AVAILABLE (ios (10.0)) PhotoOutputDelegateClass : public ObjCClass<NSObject>
{
public:
@ -972,7 +954,6 @@ private:
}
}
};
#endif
//==============================================================================
void callListeners (const Image& image)
@ -1023,10 +1004,8 @@ private:
void startRecording (const File& file, AVCaptureVideoOrientation orientationToUse)
{
#if JUCE_USE_NEW_CAMERA_API
if (@available (iOS 10.0, *))
printVideoOutputDebugInfo (movieFileOutput);
#endif
auto url = [NSURL fileURLWithPath: juceStringToNS (file.getFullPathName())
isDirectory: NO];
@ -1332,6 +1311,4 @@ String CameraDevice::getFileExtension()
return ".mov";
}
#if JUCE_USE_NEW_CAMERA_API
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
#endif
JUCE_END_IGNORE_WARNINGS_GCC_LIKE