diff --git a/Parse/Internal/PFAlertView.h b/Parse/Internal/PFAlertView.h index ac678205b..bddaf301b 100644 --- a/Parse/Internal/PFAlertView.h +++ b/Parse/Internal/PFAlertView.h @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import #import typedef void(^PFAlertViewCompletion)(NSUInteger selectedOtherButtonIndex); @@ -17,6 +18,6 @@ typedef void(^PFAlertViewCompletion)(NSUInteger selectedOtherButtonIndex); message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSArray *)otherButtonTitles - completion:(PFAlertViewCompletion)completion; + completion:(PFAlertViewCompletion)completion NS_EXTENSION_UNAVAILABLE_IOS(""); @end diff --git a/Parse/Internal/PFApplication.h b/Parse/Internal/PFApplication.h index fb87db63a..9365e0ab3 100644 --- a/Parse/Internal/PFApplication.h +++ b/Parse/Internal/PFApplication.h @@ -9,12 +9,21 @@ #import +#if TARGET_OS_IPHONE +#import +#else +#import +@compatibility_alias UIApplication NSApplication; +#endif + /*! `PFApplication` class provides a centralized way to get the information about the current application, or the environment it's running in. Please note, that all device specific things - should go to . */ @interface PFApplication : NSObject +@property (nonatomic, strong, readonly) UIApplication *systemApplication; + @property (nonatomic, assign, readonly, getter=isAppStoreEnvironment) BOOL appStoreEnvironment; @property (nonatomic, assign, readonly, getter=isExtensionEnvironment) BOOL extensionEnvironment; diff --git a/Parse/Internal/PFApplication.m b/Parse/Internal/PFApplication.m index 43e97aa00..b21d11bc0 100644 --- a/Parse/Internal/PFApplication.m +++ b/Parse/Internal/PFApplication.m @@ -48,7 +48,7 @@ - (BOOL)isExtensionEnvironment { - (NSInteger)iconBadgeNumber { #if TARGET_OS_IPHONE - return [UIApplication sharedApplication].applicationIconBadgeNumber; + return self.systemApplication.applicationIconBadgeNumber; #else // Make sure not to use `NSApp` here, because it doesn't work sometimes, // `NSApplication +sharedApplication` does though. @@ -72,11 +72,16 @@ - (NSInteger)iconBadgeNumber { - (void)setIconBadgeNumber:(NSInteger)iconBadgeNumber { if (self.iconBadgeNumber != iconBadgeNumber) { #if TARGET_OS_IPHONE - [UIApplication sharedApplication].applicationIconBadgeNumber = iconBadgeNumber; + self.systemApplication.applicationIconBadgeNumber = iconBadgeNumber; #else [[NSApplication sharedApplication] dockTile].badgeLabel = [@(iconBadgeNumber) stringValue]; #endif } } +- (UIApplication *)systemApplication { + // Workaround to make `sharedApplication` still be called even if compiling for App Extensions or WatchKit apps. + return [UIApplication performSelector:@selector(sharedApplication)]; +} + @end diff --git a/Parse/Internal/PFLocationManager.m b/Parse/Internal/PFLocationManager.m index c8c11c251..dc4bdaf13 100644 --- a/Parse/Internal/PFLocationManager.m +++ b/Parse/Internal/PFLocationManager.m @@ -13,13 +13,7 @@ #import "PFConstants.h" #import "PFGeoPoint.h" - -#if !TARGET_OS_IPHONE - -// To let us compile for OSX. -@compatibility_alias UIApplication NSApplication; - -#endif +#import "PFApplication.h" @interface PFLocationManager () @@ -66,7 +60,7 @@ - (instancetype)init { - (instancetype)initWithSystemLocationManager:(CLLocationManager *)manager { return [self initWithSystemLocationManager:manager - application:[UIApplication sharedApplication] + application:[PFApplication currentApplication].systemApplication bundle:[NSBundle mainBundle]]; } diff --git a/Parse/Internal/Push/PFPushPrivate.h b/Parse/Internal/Push/PFPushPrivate.h index 5f685a001..d45d114a9 100644 --- a/Parse/Internal/Push/PFPushPrivate.h +++ b/Parse/Internal/Push/PFPushPrivate.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN #if TARGET_OS_IPHONE -+ (void)showAlertViewWithTitle:(nullable NSString *)title message:(nullable NSString *)message; ++ (void)showAlertViewWithTitle:(nullable NSString *)title message:(nullable NSString *)message NS_EXTENSION_UNAVAILABLE_IOS(""); + (void)playVibrate; + (void)playAudioWithName:(nullable NSString *)audioName; diff --git a/Parse/PFNetworkActivityIndicatorManager.m b/Parse/PFNetworkActivityIndicatorManager.m index 6fb3b0466..5d7fbfe17 100644 --- a/Parse/PFNetworkActivityIndicatorManager.m +++ b/Parse/PFNetworkActivityIndicatorManager.m @@ -142,7 +142,7 @@ - (void)_updateNetworkActivityIndicatorVisibilityAfterDelay { } } -- (void)_updateNetworkActivityIndicatorVisibility { +- (void)_updateNetworkActivityIndicatorVisibility NS_EXTENSION_UNAVAILABLE_IOS("") { if (![PFApplication currentApplication].extensionEnvironment) { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:self.networkActivityIndicatorVisible]; } diff --git a/Parse/PFPush.h b/Parse/PFPush.h index a5c058414..afdca65fa 100644 --- a/Parse/PFPush.h +++ b/Parse/PFPush.h @@ -386,7 +386,7 @@ PF_ASSUME_NONNULL_BEGIN @param userInfo The userInfo dictionary you get in `appplication:didReceiveRemoteNotification:`. */ -+ (void)handlePush:(PF_NULLABLE NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0); ++ (void)handlePush:(PF_NULLABLE NSDictionary *)userInfo NS_AVAILABLE_IOS(3_0) PF_EXTENSION_UNAVAILABLE(""); ///-------------------------------------- /// @name Managing Channel Subscriptions