Skip to content

Commit b703ab6

Browse files
committed
add OpenNotificationToLaunchApp event
1 parent b748d2d commit b703ab6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

ios/RCTJPushModule/RCTJPushModule/RCTJPushModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
#define kJPFDidReceiveRemoteNotification @"kJPFDidReceiveRemoteNotification"
2222

23-
#define kJPFOpenNotification @"kJPFOpenNotification" // 通过点击通知 Notification 启动应用
23+
#define kJPFOpenNotification @"kJPFOpenNotification" // 通过点击通知事件
24+
#define kJPFOpenNotificationToLaunchApp @"kJPFOpenNotificationToLaunchApp" // 通过点击通知启动应用
2425

2526
@interface RCTJPushModule : NSObject <RCTBridgeModule>
2627
@property(strong,nonatomic)RCTResponseSenderBlock asyCallback;

ios/RCTJPushModule/RCTJPushModule/RCTJPushModule.m

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ - (id)init {
8686
name:kJPFOpenNotification
8787
object:nil];
8888

89+
[defaultCenter addObserver:self
90+
selector:@selector(openNotificationToLaunchApp:)
91+
name:kJPFOpenNotificationToLaunchApp
92+
object:nil];
93+
94+
if ([RCTJPushActionQueue sharedInstance].openedLocalNotification != nil) {
95+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
96+
}
97+
8998
return self;
9099
}
91100

@@ -94,11 +103,11 @@ - (void)reactJSDidload {
94103
[[RCTJPushActionQueue sharedInstance] scheduleNotificationQueue];
95104

96105
if ([RCTJPushActionQueue sharedInstance].openedRemoteNotification != nil) {
97-
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:[RCTJPushActionQueue sharedInstance].openedRemoteNotification];
106+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedRemoteNotification];
98107
}
99108

100109
if ([RCTJPushActionQueue sharedInstance].openedLocalNotification != nil) {
101-
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotification object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
110+
[[NSNotificationCenter defaultCenter] postNotificationName:kJPFOpenNotificationToLaunchApp object:[RCTJPushActionQueue sharedInstance].openedLocalNotification];
102111
}
103112

104113
}
@@ -126,6 +135,11 @@ - (void)setBridge:(RCTBridge *)bridge {
126135
}
127136
}
128137

138+
- (void)openNotificationToLaunchApp:(NSNotification *)notification {
139+
id obj = [notification object];
140+
[self.bridge.eventDispatcher sendAppEventWithName:@"OpenNotificationToLaunchApp" body:obj];
141+
}
142+
129143
- (void)openNotification:(NSNotification *)notification {
130144
id obj = [notification object];
131145
[self.bridge.eventDispatcher sendAppEventWithName:@"OpenNotification" body:obj];

0 commit comments

Comments
 (0)