Skip to content

Commit

Permalink
iOS add removeLocalNotification clearLocalNotifications api
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminlinux committed Oct 19, 2018
1 parent a7b8389 commit 6befe18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 8 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ export default class JPush {
}

/**
* Android Only
* Android Only.
* 删除通知栏指定的推送。
*/
static clearNotificationById (id) {
JPushModule.clearNotificationById(id)
if (Platform.OS == "android") {
JPushModule.clearNotificationById(id)
} else {
console.warn("iOS 没有提供该方法!")
}
}

/**
Expand Down Expand Up @@ -631,22 +636,14 @@ export default class JPush {
* 移除所有的本地通知
*/
static clearLocalNotifications() {
if (Platform.OS == "android") {
JPushModule.clearLocalNotifications()
} else {

}
}

/**
* 移除指定的本地通知
* 移除指定未触发的本地通知。
*/
static removeLocalNotification(id) {
if (Platform.OS == "android") {
JPushModule.removeLocalNotification(id)
} else {

}
}

/**
Expand Down
7 changes: 6 additions & 1 deletion ios/RCTJPushModule/RCTJPushModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -870,12 +870,17 @@ - (void)didRegistRemoteNotification:(NSString *)token {
}
}

RCT_EXPORT_METHOD(clearNotificationById:(NSInteger)identify) {
RCT_EXPORT_METHOD(removeLocalNotification:(NSInteger)identify) {
JPushNotificationIdentifier *pushIdentify = [[JPushNotificationIdentifier alloc] init];
pushIdentify.identifiers = @[[@(identify) description]];
[JPUSHService removeNotification: pushIdentify];
}

RCT_EXPORT_METHOD(clearLocalNotifications) {
[JPUSHService removeNotification: nil];
}


- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
NSDictionary * userInfo = notification.request.content.userInfo;
[JPUSHService handleRemoteNotification:userInfo];
Expand Down

0 comments on commit 6befe18

Please sign in to comment.