Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add resetBadge #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions ios/Classes/JPushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
[self deleteAlias:call result:result];
} else if([@"setBadge" isEqualToString:call.method]) {
[self setBadge:call result:result];
} else if([@"resetBadge" isEqualToString:call.method]) {
[self resetBadge:call result:result];
} else if([@"stopPush" isEqualToString:call.method]) {
[self stopPush:call result:result];
} else if([@"resumePush" isEqualToString:call.method]) {
Expand Down Expand Up @@ -311,6 +313,12 @@ - (void)setBadge:(FlutterMethodCall*)call result:(FlutterResult)result {
[JPUSHService setBadge: badge];
}

- (void)resetBadge:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"resetBadge:");
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[JPUSHService resetBadge];
}

- (void)stopPush:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"stopPush:");
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
Expand Down
9 changes: 9 additions & 0 deletions lib/jpush_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ class JPush {
await _channel.invokeMethod('setBadge', {"badge": badge});
}

///
/// 清空应用Badge(小红点)
///
Future resetBadge() async {
print(flutter_log + "resetBadge:");

await _channel.invokeMethod('resetBadge');
}

///
/// 停止接收推送,调用该方法后应用将不再受到推送,如果想要重新收到推送可以调用 resumePush。
///
Expand Down