Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.

Commit 933eaff

Browse files
committed
增加watch事件,统一一些命名和修饰符和版本判断
1 parent 4016a1e commit 933eaff

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

BeeHive/BHAppDelegate.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ typedef void (^BHNotificationCompletionHandler)();
2828
@property (nonatomic, strong) NSError *notificationsError;
2929
@property (nonatomic, strong) NSData *deviceToken;
3030
@property (nonatomic, strong) NSDictionary *userInfo;
31-
@property (nonatomic, weak) BHNotificationResultHandler notificationResultHander;
31+
@property (nonatomic, copy) BHNotificationResultHandler notificationResultHander;
3232
@property (nonatomic, strong) UILocalNotification *localNotification;
3333
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
3434
@property (nonatomic, strong) UNNotification *notification;
3535
@property (nonatomic, strong) UNNotificationResponse *notificationResponse;
36-
@property (nonatomic, weak) BHNotificationPresentationOptionsHandler notificationPresentationOptionsHandler;
37-
@property (nonatomic, weak) BHNotificationCompletionHandler notificationCompletionHandler;
36+
@property (nonatomic, copy) BHNotificationPresentationOptionsHandler notificationPresentationOptionsHandler;
37+
@property (nonatomic, copy) BHNotificationCompletionHandler notificationCompletionHandler;
3838
@property (nonatomic, strong) UNUserNotificationCenter *center;
3939
#endif
4040

@@ -43,33 +43,41 @@ typedef void (^BHNotificationCompletionHandler)();
4343
@interface BHOpenURLItem : NSObject
4444

4545
@property (nonatomic, strong) NSURL *openURL;
46-
@property (nonatomic, strong) NSString *sourceApplication;
46+
@property (nonatomic, copy) NSString *sourceApplication;
4747
@property (nonatomic, strong) id annotation;
4848
@property (nonatomic, strong) NSDictionary *options;
4949

5050
@end
5151

52-
typedef void (^shortcutItemCompletionHandler)(BOOL);
52+
typedef void (^BHShortcutCompletionHandler)(BOOL);
5353

5454
@interface BHShortcutItem : NSObject
5555

5656
#if __IPHONE_OS_VERSION_MAX_ALLOWED > 80400
5757
@property(nonatomic, strong) UIApplicationShortcutItem *shortcutItem;
58-
@property(nonatomic, copy) shortcutItemCompletionHandler scompletionHandler;
58+
@property(nonatomic, copy) BHShortcutCompletionHandler scompletionHandler;
5959
#endif
6060

6161
@end
6262

6363

64-
typedef void (^restorationHandler)(NSArray *);
64+
typedef void (^BHUserActivityRestorationHandler)(NSArray *);
6565

6666
@interface BHUserActivityItem : NSObject
6767

68-
@property (nonatomic, strong) NSString *userActivityType;
68+
@property (nonatomic, copy) NSString *userActivityType;
6969
@property (nonatomic, strong) NSUserActivity *userActivity;
7070
@property (nonatomic, strong) NSError *userActivityError;
71-
@property (nonatomic, strong) restorationHandler restorationHandler;
71+
@property (nonatomic, copy) BHUserActivityRestorationHandler restorationHandler;
7272

73+
@end
74+
75+
typedef void (^BHWatchReplyHandler)(NSDictionary *replyInfo);
76+
77+
@interface BHWatchItem : NSObject
78+
79+
@property (nonatomic, strong) NSDictionary *userInfo;
80+
@property (nonatomic, copy) BHWatchReplyHandler replyHandler;
7381

7482
@end
7583

BeeHive/BHAppDelegate.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4646
}
4747

4848

49-
#if __IPHONE_OS_VERSION_MAX_ALLOWED > 80400
49+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80400
5050

5151
-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
5252
{
@@ -90,7 +90,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
9090
return YES;
9191
}
9292

93-
#if __IPHONE_OS_VERSION_MAX_ALLOWED > 80400
93+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80400
9494
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
9595
{
9696

@@ -138,18 +138,18 @@ - (void)application:(UIApplication *)application didReceiveLocalNotification:(UI
138138
[[BHModuleManager sharedManager] triggerEvent:BHMDidReceiveLocalNotificationEvent];
139139
}
140140

141-
#if __IPHONE_OS_VERSION_MAX_ALLOWED > 80000
141+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
142142
- (void)application:(UIApplication *)application didUpdateUserActivity:(NSUserActivity *)userActivity
143143
{
144-
if([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
144+
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0f){
145145
[[BeeHive shareInstance].context.userActivityItem setUserActivity: userActivity];
146146
[[BHModuleManager sharedManager] triggerEvent:BHMDidUpdateUserActivityEvent];
147147
}
148148
}
149149

150150
- (void)application:(UIApplication *)application didFailToContinueUserActivityWithType:(NSString *)userActivityType error:(NSError *)error
151151
{
152-
if([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
152+
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0f){
153153
[[BeeHive shareInstance].context.userActivityItem setUserActivityType: userActivityType];
154154
[[BeeHive shareInstance].context.userActivityItem setUserActivityError: error];
155155
[[BHModuleManager sharedManager] triggerEvent:BHMDidFailToContinueUserActivityEvent];
@@ -158,7 +158,7 @@ - (void)application:(UIApplication *)application didFailToContinueUserActivityWi
158158

159159
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
160160
{
161-
if([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
161+
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0f){
162162
[[BeeHive shareInstance].context.userActivityItem setUserActivity: userActivity];
163163
[[BeeHive shareInstance].context.userActivityItem setRestorationHandler: restorationHandler];
164164
[[BHModuleManager sharedManager] triggerEvent:BHMContinueUserActivityEvent];
@@ -168,12 +168,19 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserAct
168168

169169
- (BOOL)application:(UIApplication *)application willContinueUserActivityWithType:(NSString *)userActivityType
170170
{
171-
if([UIDevice currentDevice].systemVersion.floatValue > 8.0f){
171+
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0f){
172172
[[BeeHive shareInstance].context.userActivityItem setUserActivityType: userActivityType];
173173
[[BHModuleManager sharedManager] triggerEvent:BHMWillContinueUserActivityEvent];
174174
}
175175
return YES;
176176
}
177+
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(nullable NSDictionary *)userInfo reply:(void(^)(NSDictionary * __nullable replyInfo))reply {
178+
if([UIDevice currentDevice].systemVersion.floatValue >= 8.0f){
179+
[BeeHive shareInstance].context.watchItem.userInfo = userInfo;
180+
[BeeHive shareInstance].context.watchItem.replyHandler = reply;
181+
[[BHModuleManager sharedManager] triggerEvent:BHMHandleWatchKitExtensionRequestEvent];
182+
}
183+
}
177184
#endif
178185
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
179186
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {

BeeHive/BHContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ typedef enum
5555
//user Activity Model
5656
@property (nonatomic, strong) BHUserActivityItem *userActivityItem;
5757

58+
//watch Model
59+
@property (nonatomic, strong) BHWatchItem *watchItem;
60+
5861
//custom param
5962
@property (nonatomic, copy) NSDictionary *customParam;
6063

BeeHive/BHModuleManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef NS_ENUM(NSInteger, BHModuleEventType)
3939
BHMContinueUserActivityEvent,
4040
BHMDidFailToContinueUserActivityEvent,
4141
BHMDidUpdateUserActivityEvent,
42+
BHMHandleWatchKitExtensionRequestEvent,
4243
BHMDidCustomEvent = 1000
4344

4445
};

BeeHive/BHModuleManager.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
static NSString *kContinueUserActivitySelector = @"modContinueUserActivity:";
4242
static NSString *kDidUpdateContinueUserActivitySelector = @"modDidUpdateContinueUserActivity:";
4343
static NSString *kFailToContinueUserActivitySelector = @"modDidFailToContinueUserActivity:";
44+
static NSString *kHandleWatchKitExtensionRequestSelector = @"modHandleWatchKitExtensionRequest:";
4445
static NSString *kAppCustomSelector = @"modDidCustomEvent:";
4546

4647

@@ -420,6 +421,7 @@ - (NSMutableArray *)BHModules
420421
@(BHMDidUpdateUserActivityEvent):kDidUpdateContinueUserActivitySelector,
421422

422423
@(BHMQuickActionEvent):kQuickActionSelector,
424+
@(BHMHandleWatchKitExtensionRequestEvent):kHandleWatchKitExtensionRequestSelector,
423425
@(BHMDidCustomEvent):kAppCustomSelector,
424426
}.mutableCopy;
425427
}

BeeHive/BHModuleProtocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,7 @@
7575

7676
- (void)modDidUpdateContinueUserActivity:(BHContext *)context;
7777

78+
- (void)modHandleWatchKitExtensionRequest:(BHContext *)context;
79+
7880
- (void)modDidCustomEvent:(BHContext *)context;
7981
@end

0 commit comments

Comments
 (0)