diff --git a/android/build.gradle b/android/build.gradle index 99e966ac..d2ba6954 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -34,8 +34,8 @@ android { } dependencies { - implementation 'cn.jiguang.sdk:jpush:3.9.0' - implementation 'cn.jiguang.sdk:jcore:2.6.0' + implementation 'cn.jiguang.sdk:jpush:4.0.6' + implementation 'cn.jiguang.sdk:jcore:2.7.8' // implementation 'com.android.support:appcompat-v7:28.+' compileOnly files('libs/flutter.jar') diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ea402fd1..c74af106 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +#distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java index 2b6f4d34..1730bf5a 100644 --- a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java +++ b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java @@ -344,7 +344,7 @@ private void isNotificationEnabled(MethodCall call, Result result) { int isEnabled = JPushInterface.isNotificationEnabled(registrar.context()); //1表示开启,0表示关闭,-1表示检测失败 HashMap map = new HashMap(); - map.put("isEnabled",isEnabled==1?true:false); + map.put("isEnabled", isEnabled == 1); runMainThread(map,result,null); } diff --git a/ios/Classes/JPushPlugin.m b/ios/Classes/JPushPlugin.m index 5d225312..38760338 100644 --- a/ios/Classes/JPushPlugin.m +++ b/ios/Classes/JPushPlugin.m @@ -138,6 +138,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]) { @@ -312,6 +314,13 @@ - (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]; diff --git a/ios/jpush_flutter.podspec b/ios/jpush_flutter.podspec index 73cf84d6..caa4178a 100644 --- a/ios/jpush_flutter.podspec +++ b/ios/jpush_flutter.podspec @@ -15,8 +15,8 @@ A new flutter plugin project. s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'JCore','2.4.0' - s.dependency 'JPush','3.4.0' + s.dependency 'JCore','2.6.2' + s.dependency 'JPush','3.5.2' s.ios.deployment_target = '8.0' s.static_framework = true diff --git a/lib/jpush_flutter.dart b/lib/jpush_flutter.dart index 8f343a72..067a5065 100644 --- a/lib/jpush_flutter.dart +++ b/lib/jpush_flutter.dart @@ -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。 /// diff --git a/pubspec.yaml b/pubspec.yaml index f896a89c..bb05d4a4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,7 +9,7 @@ environment: flutter: ">=1.10.0" dependencies: - platform: ^2.0.0 + platform: ^3.0.0 flutter: sdk: flutter