From 6114053dacef6a6a51cabb3b704898e9fa0364af Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Tue, 18 Dec 2018 11:12:43 +0800 Subject: [PATCH] add debug mode config update to 0.0.7 --- .packages | 2 +- android/build.gradle | 4 +-- .../java/com/jiguang/jpush/JPushPlugin.java | 8 ++--- example/ios/Runner/AppDelegate.m | 1 + example/lib/main.dart | 3 +- example/pubspec.lock | 2 +- ios/Classes/JPushPlugin.m | 12 ++++++- lib/jpush_flutter.dart | 31 +++++++++++-------- pubspec.yaml | 2 +- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/.packages b/.packages index 3447829..7f1f499 100644 --- a/.packages +++ b/.packages @@ -1,4 +1,4 @@ -# Generated by pub on 2018-10-08 23:40:55.475551. +# Generated by pub on 2018-12-18 11:12:10.903707. analyzer:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.33.0/lib/ args:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.0/lib/ async:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib/ diff --git a/android/build.gradle b/android/build.gradle index 75bd001..f178066 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -34,6 +34,6 @@ android { } dependencies { - compile 'cn.jiguang.sdk:jpush:3.1.6' // 此处以JPush 3.1.6 版本为例。 - compile 'cn.jiguang.sdk:jcore:1.2.5' // 此处以JCore 1.2.5 版本为例。 + implementation 'cn.jiguang.sdk:jpush:3.1.6' // 此处以JPush 3.1.6 版本为例。 + implementation 'cn.jiguang.sdk:jcore:1.2.5' // 此处以JCore 1.2.5 版本为例。 } \ No newline at end of file diff --git a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java index 39880a4..1cfd45c 100644 --- a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java +++ b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java @@ -96,8 +96,9 @@ public class JPushPlugin implements MethodCallHandler { } public void setup(MethodCall call, Result result) { - - JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志 + HashMap map = call.arguments(); + boolean debug = (boolean)map.get("debug"); + JPushInterface.setDebugMode(debug); JPushInterface.init(registrar.context()); // 初始化 JPush JPushPlugin.instance.dartIsReady = true; @@ -227,9 +228,6 @@ public class JPushPlugin implements MethodCallHandler { } - - - /** * 接收自定义消息,通知,通知点击事件等事件的广播 * 文档链接:http://docs.jiguang.cn/client/android_api/ diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 59a72e9..f4b9286 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -8,6 +8,7 @@ [GeneratedPluginRegistrant registerWithRegistry:self]; // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; + } @end diff --git a/example/lib/main.dart b/example/lib/main.dart index 963823b..478bf0f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -35,7 +35,8 @@ final JPush jpush = new JPush(); jpush.setup( appKey: "a1703c14b186a68a66ef86c1", channel: "theChannel", - production: false + production: false, + // debug: true, ); jpush.applyPushAuthority(new NotificationSettingsIOS( sound: false, diff --git a/example/pubspec.lock b/example/pubspec.lock index 108b700..612d0a5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -136,7 +136,7 @@ packages: path: ".." relative: true source: path - version: "0.0.5" + version: "0.0.7" js: dependency: transitive description: diff --git a/ios/Classes/JPushPlugin.m b/ios/Classes/JPushPlugin.m index bf6c7bb..5a6bd14 100644 --- a/ios/Classes/JPushPlugin.m +++ b/ios/Classes/JPushPlugin.m @@ -150,9 +150,17 @@ static NSMutableArray* getRidResults; } } + + - (void)setup:(FlutterMethodCall*)call result:(FlutterResult)result { NSDictionary *arguments = call.arguments; - + NSNumber *debug = arguments[@"debug"]; + if ([debug boolValue]) { + [JPUSHService setDebugMode]; + } else { + [JPUSHService setLogOFF]; + } + [JPUSHService setupWithOption:_launchNotification appKey:arguments[@"appKey"] channel:arguments[@"channel"] @@ -383,6 +391,8 @@ static NSMutableArray* getRidResults; result(@[@[]]); } + + - (void)dealloc { _isJPushDidLogin = NO; [[NSNotificationCenter defaultCenter] removeObserver:self]; diff --git a/lib/jpush_flutter.dart b/lib/jpush_flutter.dart index cf4edde..c469a7f 100644 --- a/lib/jpush_flutter.dart +++ b/lib/jpush_flutter.dart @@ -29,8 +29,9 @@ class JPush { String appKey, String channel, bool production, + bool debug = false, }) { - _channel.invokeMethod('setup', { 'appKey': appKey, 'channel': channel, 'production': production }); + _channel.invokeMethod('setup', { 'appKey': appKey, 'channel': channel, 'production': production, 'debug': debug}); } /// /// 初始化 JPush 必须先初始化才能执行其他操作(比如接收事件传递) @@ -154,6 +155,10 @@ class JPush { return result; } + void setDebugMode() { + _channel.invokeMethod('setDebugMode'); + } + /// /// iOS Only /// 设置应用 Badge(小红点) @@ -239,18 +244,18 @@ class NotificationSettingsIOS { - /// @property {number} [buildId] - 通知样式:1 为基础样式,2 为自定义样式(需先调用 `setStyleCustom` 设置自定义样式) - /// @property {number} [id] - 通知 id, 可用于取消通知 - /// @property {string} [title] - 通知标题 - /// @property {string} [content] - 通知内容 - /// @property {object} [extra] - extra 字段 - /// @property {number} [fireTime] - 通知触发时间(毫秒) - /// // iOS Only - /// @property {number} [badge] - 本地推送触发后应用角标值 - /// // iOS Only - /// @property {string} [soundName] - 指定推送的音频文件 - /// // iOS 10+ Only - /// @property {string} [subtitle] - 子标题 + /// @property {number} [buildId] - 通知样式:1 为基础样式,2 为自定义样式(需先调用 `setStyleCustom` 设置自定义样式) + /// @property {number} [id] - 通知 id, 可用于取消通知 + /// @property {string} [title] - 通知标题 + /// @property {string} [content] - 通知内容 + /// @property {object} [extra] - extra 字段 + /// @property {number} [fireTime] - 通知触发时间(毫秒) + /// // iOS Only + /// @property {number} [badge] - 本地推送触发后应用角标值 + /// // iOS Only + /// @property {string} [soundName] - 指定推送的音频文件 + /// // iOS 10+ Only + /// @property {string} [subtitle] - 子标题 class LocalNotification { final int buildId;//? diff --git a/pubspec.yaml b/pubspec.yaml index 72825aa..41ca24f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: jpush_flutter description: Offically supported JPush Flutter plugin. -version: 0.0.6 +version: 0.0.7 author: huminios homepage: https://www.jiguang.cn