From 0905fe9820bdfc43bdd67d89d09753850c7af754 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Tue, 18 Dec 2018 14:02:24 +0800 Subject: [PATCH] android add dynamic set channel --- android/src/main/java/com/jiguang/jpush/JPushPlugin.java | 5 +++++ example/lib/main.dart | 2 +- lib/jpush_flutter.dart | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java index 1cfd45c..ca3aeca 100644 --- a/android/src/main/java/com/jiguang/jpush/JPushPlugin.java +++ b/android/src/main/java/com/jiguang/jpush/JPushPlugin.java @@ -99,7 +99,12 @@ public class JPushPlugin implements MethodCallHandler { HashMap map = call.arguments(); boolean debug = (boolean)map.get("debug"); JPushInterface.setDebugMode(debug); + JPushInterface.init(registrar.context()); // 初始化 JPush + + String channel = (String)map.get("channel"); + JPushInterface.setChannel(registrar.context(), channel); + JPushPlugin.instance.dartIsReady = true; // try to clean getRid cache diff --git a/example/lib/main.dart b/example/lib/main.dart index 478bf0f..4d7f601 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -36,7 +36,7 @@ final JPush jpush = new JPush(); appKey: "a1703c14b186a68a66ef86c1", channel: "theChannel", production: false, - // debug: true, + debug: true, ); jpush.applyPushAuthority(new NotificationSettingsIOS( sound: false, diff --git a/lib/jpush_flutter.dart b/lib/jpush_flutter.dart index 726806f..b8b6e87 100644 --- a/lib/jpush_flutter.dart +++ b/lib/jpush_flutter.dart @@ -27,8 +27,8 @@ class JPush { void setup({ String appKey, - String channel, bool production, + String channel = '', bool debug = false, }) { _channel.invokeMethod('setup', { 'appKey': appKey, 'channel': channel, 'production': production, 'debug': debug});