Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Parse/Internal/PFAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef void(^PFAlertViewCompletion)(NSUInteger selectedOtherButtonIndex);
Expand All @@ -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
9 changes: 9 additions & 0 deletions Parse/Internal/PFApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@

#import <Foundation/Foundation.h>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <AppKit/AppKit.h>
@compatibility_alias UIApplication NSApplication;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's my holy water when I need it?

#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 <PFDevice>.
*/
@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;

Expand Down
9 changes: 7 additions & 2 deletions Parse/Internal/PFApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
10 changes: 2 additions & 8 deletions Parse/Internal/PFLocationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 () <CLLocationManagerDelegate>

Expand Down Expand Up @@ -66,7 +60,7 @@ - (instancetype)init {

- (instancetype)initWithSystemLocationManager:(CLLocationManager *)manager {
return [self initWithSystemLocationManager:manager
application:[UIApplication sharedApplication]
application:[PFApplication currentApplication].systemApplication
bundle:[NSBundle mainBundle]];
}

Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Push/PFPushPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Parse/PFNetworkActivityIndicatorManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ - (void)_updateNetworkActivityIndicatorVisibilityAfterDelay {
}
}

- (void)_updateNetworkActivityIndicatorVisibility {
- (void)_updateNetworkActivityIndicatorVisibility NS_EXTENSION_UNAVAILABLE_IOS("") {
if (![PFApplication currentApplication].extensionEnvironment) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:self.networkActivityIndicatorVisible];
}
Expand Down
2 changes: 1 addition & 1 deletion Parse/PFPush.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down