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

修复 plugin 未配置 #194

Open
wants to merge 14 commits 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
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion android/src/main/java/com/jiguang/jpush/JPushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private void isNotificationEnabled(MethodCall call, Result result) {
int isEnabled = JPushInterface.isNotificationEnabled(registrar.context());
//1表示开启,0表示关闭,-1表示检测失败
HashMap<String, Object> map = new HashMap();
map.put("isEnabled",isEnabled==1?true:false);
map.put("isEnabled", isEnabled == 1);

runMainThread(map,result,null);
}
Expand Down
9 changes: 9 additions & 0 deletions ios/Classes/JPushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions ios/jpush_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
flutter: ">=1.10.0"

dependencies:
platform: ^2.0.0
platform: ^3.0.0
flutter:
sdk: flutter

Expand Down