Skip to content

Commit b71c031

Browse files
committed
Merge pull request #321 from ParsePlatform/nlutsenko.watchos.application
Update PFApplication to compile for watchOS.
2 parents 14f971a + 3d06bda commit b71c031

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Parse/Internal/PFApplication.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99

1010
#import <Foundation/Foundation.h>
1111

12-
#if TARGET_OS_IPHONE
12+
#import <Parse/PFConstants.h>
13+
14+
#if TARGET_OS_IOS
1315
#import <UIKit/UIKit.h>
14-
#else
16+
#elif TARGET_OS_WATCH
17+
@class UIApplication;
18+
#elif TARGET_OS_MAC
1519
#import <AppKit/AppKit.h>
1620
@compatibility_alias UIApplication NSApplication;
1721
#endif

Parse/Internal/PFApplication.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#import "PFApplication.h"
1111

12-
#if TARGET_OS_IPHONE
12+
#if TARGET_OS_IOS
1313
#import <UIKit/UIKit.h>
14-
#else
14+
#elif !TARGET_OS_WATCH && TARGET_OS_MAC
1515
#import <AppKit/AppKit.h>
1616
#endif
1717

@@ -47,9 +47,11 @@ - (BOOL)isExtensionEnvironment {
4747
}
4848

4949
- (NSInteger)iconBadgeNumber {
50-
#if TARGET_OS_IPHONE
50+
#if TARGET_OS_WATCH
51+
return 0;
52+
#elif TARGET_OS_IOS
5153
return self.systemApplication.applicationIconBadgeNumber;
52-
#else
54+
#elif TARGET_OS_MAC
5355
// Make sure not to use `NSApp` here, because it doesn't work sometimes,
5456
// `NSApplication +sharedApplication` does though.
5557
NSString *badgeLabel = [[NSApplication sharedApplication] dockTile].badgeLabel;
@@ -71,17 +73,21 @@ - (NSInteger)iconBadgeNumber {
7173

7274
- (void)setIconBadgeNumber:(NSInteger)iconBadgeNumber {
7375
if (self.iconBadgeNumber != iconBadgeNumber) {
74-
#if TARGET_OS_IPHONE
76+
#if TARGET_OS_IOS
7577
self.systemApplication.applicationIconBadgeNumber = iconBadgeNumber;
76-
#else
78+
#elif !TARGET_OS_WATCH
7779
[[NSApplication sharedApplication] dockTile].badgeLabel = [@(iconBadgeNumber) stringValue];
7880
#endif
7981
}
8082
}
8183

8284
- (UIApplication *)systemApplication {
85+
#if TARGET_OS_WATCH
86+
return nil;
87+
#else
8388
// Workaround to make `sharedApplication` still be called even if compiling for App Extensions or WatchKit apps.
8489
return [UIApplication performSelector:@selector(sharedApplication)];
90+
#endif
8591
}
8692

8793
@end

0 commit comments

Comments
 (0)