Merge pull request #111 from jpush/dev

v0.5.0适配新版本 SDK
master
raoxudong 5 years ago committed by GitHub
commit e5ccd87f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,338 @@
{
"configVersion": 2,
"packages": [
{
"name": "analyzer",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.37.0",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "args",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/args-1.5.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "async",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.3.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "boolean_selector",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-1.0.5",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "charcode",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.1.2",
"packageUri": "lib/",
"languageVersion": "1.0"
},
{
"name": "collection",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/collection-1.14.11",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "convert",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/convert-2.1.1",
"packageUri": "lib/",
"languageVersion": "1.17"
},
{
"name": "crypto",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/crypto-2.0.6",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "csslib",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/csslib-0.16.1",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "flutter",
"rootUri": "file:///Applications/flutter/packages/flutter",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "front_end",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/front_end-0.1.20",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "glob",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/glob-1.1.7",
"packageUri": "lib/",
"languageVersion": "1.23"
},
{
"name": "html",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/html-0.14.0+2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "http",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/http-0.12.0+2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "http_multi_server",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/http_multi_server-2.1.0",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "http_parser",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/http_parser-3.1.3",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "io",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.3",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "js",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.1+1",
"packageUri": "lib/",
"languageVersion": "1.19"
},
{
"name": "kernel",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/kernel-0.3.20",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "matcher",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.5",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "meta",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.8",
"packageUri": "lib/",
"languageVersion": "1.12"
},
{
"name": "mime",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.6+3",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "mockito",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/mockito-3.0.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "multi_server_socket",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/multi_server_socket-1.0.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "node_preamble",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/node_preamble-1.4.5",
"packageUri": "lib/",
"languageVersion": "1.24"
},
{
"name": "package_config",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_config-1.0.5",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "package_resolver",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_resolver-1.0.10",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "path",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/path-1.6.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "pedantic",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/pedantic-1.8.0+1",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "platform",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/platform-2.2.0",
"packageUri": "lib/",
"languageVersion": "1.24"
},
{
"name": "pool",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/pool-1.4.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "pub_semver",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/pub_semver-1.4.2",
"packageUri": "lib/",
"languageVersion": "1.0"
},
{
"name": "shelf",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf-0.7.5",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "shelf_packages_handler",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_packages_handler-1.0.4",
"packageUri": "lib/",
"languageVersion": "1.22"
},
{
"name": "shelf_static",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_static-0.2.8",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "shelf_web_socket",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/shelf_web_socket-0.2.3",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "sky_engine",
"rootUri": "file:///Applications/flutter/bin/cache/pkg/sky_engine",
"packageUri": "lib/",
"languageVersion": "1.11"
},
{
"name": "source_map_stack_trace",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_map_stack_trace-1.1.5",
"packageUri": "lib/",
"languageVersion": "1.8"
},
{
"name": "source_maps",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_maps-0.10.8",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "source_span",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.5.5",
"packageUri": "lib/",
"languageVersion": "1.8"
},
{
"name": "stack_trace",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.9.3",
"packageUri": "lib/",
"languageVersion": "1.23"
},
{
"name": "stream_channel",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-2.0.0",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "stream_transform",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/stream_transform-0.0.19",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "string_scanner",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.0.4",
"packageUri": "lib/",
"languageVersion": "1.8"
},
{
"name": "term_glyph",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.1.0",
"packageUri": "lib/",
"languageVersion": "1.8"
},
{
"name": "test",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/test-1.6.5",
"packageUri": "lib/",
"languageVersion": "2.2"
},
{
"name": "test_api",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/test_api-0.2.6",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "test_core",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/test_core-0.2.7",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "typed_data",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.1.6",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "vector_math",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.0.8",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "vm_service_lib",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/vm_service_lib-3.22.2",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "watcher",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/watcher-0.9.7+12",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "web_socket_channel",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/web_socket_channel-1.0.14",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "yaml",
"rootUri": "file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/yaml-2.1.16",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "jpush_flutter",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.0"
}
],
"generated": "2019-12-31T07:03:35.878530Z",
"generator": "pub",
"generatorVersion": "2.7.0"
}

@ -1,4 +1,4 @@
# Generated by pub on 2019-11-19 13:53:32.095797.
# Generated by pub on 2019-12-31 15:03:35.849743.
analyzer:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.37.0/lib/
args:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/args-1.5.2/lib/
async:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.3.0/lib/
@ -19,7 +19,7 @@ io:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/io-0.3.3/lib
js:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.1+1/lib/
kernel:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/kernel-0.3.20/lib/
matcher:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.5/lib/
meta:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.7/lib/
meta:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/meta-1.1.8/lib/
mime:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/mime-0.9.6+3/lib/
mockito:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/mockito-3.0.2/lib/
multi_server_socket:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/multi_server_socket-1.0.2/lib/

@ -1,3 +1,6 @@
## 0.5.0
+ 适配最新版本 JPush SDK
+ 适配新版 SDK 的新功能接口
## 0.3.0
+ 新增:清除通知栏单条通知方法
+ 修复:点击通知栏无法获取消息问题

@ -7,7 +7,7 @@
```yaml
dependencies:
jpush_flutter: 0.3.0
jpush_flutter: 0.5.0
//github
dependencies:

@ -34,8 +34,8 @@ android {
}
dependencies {
implementation 'cn.jiguang.sdk:jpush:3.4.0'
implementation 'cn.jiguang.sdk:jcore:2.1.6'
implementation 'cn.jiguang.sdk:jpush:3.5.4'
implementation 'cn.jiguang.sdk:jcore:2.2.4'
// implementation 'com.android.support:appcompat-v7:28.+'
compileOnly files('libs/flutter.jar')

@ -14,6 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.service.JPushMessageReceiver;
import io.flutter.plugin.common.MethodChannel.Result;
@ -130,4 +131,14 @@ public class JPushEventReceiver extends JPushMessageReceiver {
}
});
}
@Override
public void onNotificationSettingsCheck(Context context, boolean isOn, int source) {
super.onNotificationSettingsCheck(context, isOn, source);
HashMap<String, Object> map = new HashMap();
map.put("isEnabled",isOn);
JPushPlugin.instance.runMainThread(map,null,"onReceiveNotificationAuthorization");
}
}

@ -3,6 +3,8 @@ package com.jiguang.jpush;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import org.json.JSONObject;
@ -106,12 +108,32 @@ public class JPushPlugin implements MethodCallHandler {
sendLocalNotification(call, result);
} else if (call.method.equals("setBadge")) {
setBadge(call, result);
} else if (call.method.equals("isNotificationEnabled")) {
isNotificationEnabled(call, result);
} else if (call.method.equals("openSettingsForNotification")) {
openSettingsForNotification(call, result);
}
else {
result.notImplemented();
}
}
// 主线程再返回数据
public void runMainThread(final Map<String,Object> map, final Result result, final String method) {
Log.d(TAG,"runMainThread:" + "map = " + map + ",method =" + method);
android.os.Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
if (result == null && method != null){
channel.invokeMethod(method,map);
} else {
result.success(map);
}
}
});
}
public void setup(MethodCall call, Result result) {
Log.d(TAG,"setup :" + call.arguments);
@ -298,6 +320,24 @@ public class JPushPlugin implements MethodCallHandler {
}
}
/// 检查当前应用的通知开关是否开启
private void isNotificationEnabled(MethodCall call, Result result) {
Log.d(TAG,"isNotificationEnabled: ");
int isEnabled = JPushInterface.isNotificationEnabled(registrar.context());
//1表示开启0表示关闭-1表示检测失败
HashMap<String, Object> map = new HashMap();
map.put("isEnabled",isEnabled==1?true:false);
runMainThread(map,result,null);
}
private void openSettingsForNotification(MethodCall call, Result result) {
Log.d(TAG,"openSettingsForNotification: " );
JPushInterface.goToAppNotificationSettings(registrar.context());
}
/**
* ,,广
* :http://docs.jiguang.cn/client/android_api/
@ -310,6 +350,8 @@ public class JPushPlugin implements MethodCallHandler {
public JPushReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

@ -0,0 +1 @@
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"jpush_flutter","dependencies":[]}]}

@ -18,3 +18,4 @@
org.gradle.jvmargs=-Xmx1536M
#systemProp.https.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1086
android.enableR8=true

@ -0,0 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.vendored_frameworks = 'Flutter.framework'
end

@ -2,9 +2,10 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Applications/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/raoxudong/JPush/jpush-github/jpush-flutter-plugin/example"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/raoxudong/JPush/jpush-github/jpush-flutter-plugin/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Applications/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "TRACK_WIDGET_CREATION=true"

@ -24,7 +24,6 @@ class _MyAppState extends State<MyApp> {
Future<void> initPlatformState() async {
String platformVersion;
try {
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
@ -32,37 +31,35 @@ class _MyAppState extends State<MyApp> {
setState(() {
debugLable = "flutter onReceiveNotification: $message";
});
},
onOpenNotification: (Map<String, dynamic> message) async {
}, onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
setState(() {
debugLable = "flutter onOpenNotification: $message";
});
},
onReceiveMessage: (Map<String, dynamic> message) async {
}, onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
setState(() {
debugLable = "flutter onReceiveMessage: $message";
});
},
);
}, onReceiveNotificationAuthorization:
(Map<String, dynamic> message) async {
print("flutter onReceiveNotificationAuthorization: $message");
setState(() {
debugLable = "flutter onReceiveNotificationAuthorization: $message";
});
});
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
jpush.setup(
appKey: "你自己应用的 AppKey",
appKey: "e58a32cb3e4469ebf31867e5", // AppKey
channel: "theChannel",
production: false,
debug: true,
);
jpush.applyPushAuthority(new NotificationSettingsIOS(
sound: true,
alert: true,
badge: true));
jpush.applyPushAuthority(
new NotificationSettingsIOS(sound: true, alert: true, badge: true));
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
@ -72,7 +69,6 @@ class _MyAppState extends State<MyApp> {
});
});
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
@ -83,8 +79,6 @@ class _MyAppState extends State<MyApp> {
});
}
//
@override
Widget build(BuildContext context) {
@ -94,16 +88,24 @@ class _MyAppState extends State<MyApp> {
title: const Text('Plugin example app'),
),
body: new Center(
child: new Column(
children:[
new Text('result: $debugLable\n'),
child: new Column(children: [
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
color: Colors.brown,
child: Text(debugLable),
width: 350,
height: 100,
),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "sendLocalNotification", onPressed: (){
new CustomButton(
title: "发本地推送",
onPressed: () {
//
var fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000);
var fireDate = DateTime.fromMillisecondsSinceEpoch(
DateTime.now().millisecondsSinceEpoch + 3000);
var localNotification = LocalNotification(
id: 234,
title: 'fadsfa',
@ -112,22 +114,24 @@ class _MyAppState extends State<MyApp> {
fireTime: fireDate,
subtitle: 'fasf',
badge: 5,
extra: {"fa": "0"}
);
jpush.sendLocalNotification(localNotification).then((res) {
extra: {"fa": "0"});
jpush
.sendLocalNotification(localNotification)
.then((res) {
setState(() {
debugLable = res;
});
});
}),
new Text(" "),
new CustomButton(title: "getLaunchAppNotification", onPressed: (){
new CustomButton(
title: "getLaunchAppNotification",
onPressed: () {
jpush.getLaunchAppNotification().then((map) {
setState(() {
debugLable = "getLaunchAppNotification success: $map";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "getLaunchAppNotification error: $error";
});
@ -138,21 +142,24 @@ class _MyAppState extends State<MyApp> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "setTags", onPressed: (){
new CustomButton(
title: "setTags",
onPressed: () {
jpush.setTags(["lala", "haha"]).then((map) {
var tags = map['tags'];
setState(() {
debugLable = "set tags success: $map $tags";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "set tags error: $error";
});
});
}),
new Text(" "),
new CustomButton(title: "addTags", onPressed: (){
new CustomButton(
title: "addTags",
onPressed: () {
jpush.addTags(["lala", "haha"]).then((map) {
var tags = map['tags'];
setState(() {
@ -165,94 +172,99 @@ class _MyAppState extends State<MyApp> {
});
}),
new Text(" "),
new CustomButton(title: "deleteTags", onPressed: (){
new CustomButton(
title: "deleteTags",
onPressed: () {
jpush.deleteTags(["lala", "haha"]).then((map) {
var tags = map['tags'];
setState(() {
debugLable = "deleteTags success: $map $tags";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "deleteTags error: $error";
});
});
}),
]
),
]),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "getAllTags", onPressed: (){
new CustomButton(
title: "getAllTags",
onPressed: () {
jpush.getAllTags().then((map) {
setState(() {
debugLable = "getAllTags success: $map";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "getAllTags error: $error";
});
});
}),
new Text(" "),
new CustomButton(title: "cleanTags", onPressed: (){
new CustomButton(
title: "cleanTags",
onPressed: () {
jpush.cleanTags().then((map) {
var tags = map['tags'];
setState(() {
debugLable = "cleanTags success: $map $tags";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "cleanTags error: $error";
});
});
}),
]
),
]),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "setAlias", onPressed: (){
new CustomButton(
title: "setAlias",
onPressed: () {
jpush.setAlias("thealias11").then((map) {
setState(() {
debugLable = "setAlias success: $map";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "setAlias error: $error";
});
});
}),
new Text(" "),
new CustomButton(title: "deleteAlias", onPressed: (){
new CustomButton(
title: "deleteAlias",
onPressed: () {
jpush.deleteAlias().then((map) {
setState(() {
debugLable = "deleteAlias success: $map";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "deleteAlias error: $error";
});
});
}),
]
),
]),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "stopPush",onPressed: (){
new CustomButton(
title: "stopPush",
onPressed: () {
jpush.stopPush();
}),
new Text(" "),
new CustomButton(title: "resumePush", onPressed: (){
new CustomButton(
title: "resumePush",
onPressed: () {
jpush.resumePush();
}),
],
@ -261,17 +273,20 @@ class _MyAppState extends State<MyApp> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(title: "clearAllNotifications",onPressed: (){
new CustomButton(
title: "clearAllNotifications",
onPressed: () {
jpush.clearAllNotifications();
}),
new Text(" "),
new CustomButton(title: "setBadge", onPressed: (){
new CustomButton(
title: "setBadge",
onPressed: () {
jpush.setBadge(66).then((map) {
setState(() {
debugLable = "setBadge success: $map";
});
})
.catchError((error) {
}).catchError((error) {
setState(() {
debugLable = "setBadge error: $error";
});
@ -279,16 +294,39 @@ class _MyAppState extends State<MyApp> {
}),
],
),
]
)
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(" "),
new CustomButton(
title: "通知授权是否打开",
onPressed: () {
jpush.isNotificationEnabled().then((bool value) {
setState(() {
debugLable = "通知授权是否打开: $value";
});
}).catchError((onError) {
setState(() {
debugLable = "通知授权是否打开: ${onError.toString()}";
});
});
}),
new Text(" "),
new CustomButton(
title: "打开系统设置",
onPressed: () {
jpush.openSettingsForNotification();
}),
],
),
])),
),
);
}
}
///
class CustomButton extends StatelessWidget {
final VoidCallback onPressed;
final String title;

@ -8,6 +8,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.36.4"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.11"
args:
dependency: transitive
description:
@ -21,7 +28,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
version: "2.4.0"
boolean_selector:
dependency: transitive
description:
@ -50,13 +57,20 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
coverage:
dependency: transitive
description:
name: coverage
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.13.3+3"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.6"
version: "2.1.3"
csslib:
dependency: transitive
description:
@ -123,6 +137,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.3"
image:
dependency: transitive
description:
name: image
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.4"
io:
dependency: transitive
description:
@ -136,7 +157,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.3.0"
version: "0.5.0"
js:
dependency: transitive
description:
@ -144,34 +165,34 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.1+1"
json_rpc_2:
kernel:
dependency: transitive
description:
name: json_rpc_2
name: kernel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
kernel:
version: "0.3.19"
logging:
dependency: transitive
description:
name: kernel
name: logging
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.19"
version: "0.11.3+2"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.5"
version: "0.12.6"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.7"
version: "1.1.8"
mime:
dependency: transitive
description:
@ -228,6 +249,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.4.0"
platform:
dependency: transitive
description:
@ -344,21 +372,21 @@ packages:
name: test
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.3"
version: "1.9.4"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.5"
version: "0.2.11"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.5"
version: "0.2.15"
typed_data:
dependency: transitive
description:
@ -373,13 +401,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
vm_service_client:
vm_service:
dependency: transitive
description:
name: vm_service_client
name: vm_service
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.6+2"
version: "2.2.0"
watcher:
dependency: transitive
description:
@ -394,6 +422,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.14"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.5.0"
yaml:
dependency: transitive
description:
@ -402,4 +437,4 @@ packages:
source: hosted
version: "2.1.16"
sdks:
dart: ">=2.2.2 <3.0.0"
dart: ">=2.6.0 <3.0.0"

@ -152,6 +152,10 @@ static NSMutableArray<FlutterResult>* getRidResults;
[self getRegistrationID:call result:result];
} else if([@"sendLocalNotification"isEqualToString:call.method]) {
[self sendLocalNotification:call result:result];
} else if([@"isNotificationEnabled"isEqualToString:call.method]) {
[self isNotificationEnabled:call result:result];
} else if([@"openSettingsForNotification"isEqualToString:call.method]) {
[self openSettingsForNotification];
} else{
result(FlutterMethodNotImplemented);
}
@ -159,6 +163,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
- (void)setup:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"setup:");
NSDictionary *arguments = call.arguments;
@ -436,6 +441,30 @@ static NSMutableArray<FlutterResult>* getRidResults;
result(@[@[]]);
}
/// 检查当前应用的通知开关是否开启
- (void)isNotificationEnabled:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"isNotificationEnabled:");
[JPUSHService requestNotificationAuthorization:^(JPAuthorizationStatus status) {
BOOL isEnabled = NO;
if (status == JPAuthorizationStatusAuthorized) {
isEnabled = YES;
}
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:isEnabled],@"isEnabled", nil];
dispatch_async(dispatch_get_main_queue(), ^{
result(dict);
});
}];
}
- (void)openSettingsForNotification {
JPLog(@"openSettingsForNotification:");
[JPUSHService openSettingsForNotification:^(BOOL success) {
JPLog(@"openSettingsForNotification: %@",@(success));
}];
}
- (void)dealloc {
@ -525,6 +554,19 @@ didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSe
completionHandler();
}
- (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info {
BOOL isEnabled = NO;
if (status == JPAuthorizationStatusAuthorized) {
isEnabled = YES;
}
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:isEnabled],@"isEnabled", nil];
__weak typeof(self) weakself = self;
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(self) strongself = weakself;
[strongself.channel invokeMethod:@"onReceiveNotificationAuthorization" arguments: dict];
});
}
- (NSMutableDictionary *)jpushFormatAPNSDic:(NSDictionary *)dic {
NSMutableDictionary *extras = @{}.mutableCopy;
for (NSString *key in dic) {

@ -23,6 +23,7 @@ class JPush {
EventHandler _onReceiveNotification;
EventHandler _onOpenNotification;
EventHandler _onReceiveMessage;
EventHandler _onReceiveNotificationAuthorization;
void setup({
String appKey,
@ -47,12 +48,14 @@ class JPush {
EventHandler onReceiveNotification,
EventHandler onOpenNotification,
EventHandler onReceiveMessage,
EventHandler onReceiveNotificationAuthorization,
}) {
print(flutter_log + "addEventHandler:");
_onReceiveNotification = onReceiveNotification;
_onOpenNotification = onOpenNotification;
_onReceiveMessage = onReceiveMessage;
_onReceiveNotificationAuthorization = onReceiveNotificationAuthorization;
_channel.setMethodCallHandler(_handleMethod);
}
@ -66,12 +69,15 @@ class JPush {
return _onOpenNotification(call.arguments.cast<String, dynamic>());
case "onReceiveMessage":
return _onReceiveMessage(call.arguments.cast<String, dynamic>());
case "onReceiveNotificationAuthorization":
return _onReceiveNotificationAuthorization(call.arguments.cast<String, dynamic>());
default:
throw new UnsupportedError("Unrecognized Event");
}
}
///
/// iOS Only
///
///
void applyPushAuthority(
@ -278,6 +284,17 @@ class JPush {
}
/// API
Future<bool> isNotificationEnabled() async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('isNotificationEnabled');
bool isEnabled = result["isEnabled"];
return isEnabled;
}
/// API
void openSettingsForNotification() {
_channel.invokeMethod('openSettingsForNotification');
}
}

@ -145,7 +145,7 @@ packages:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.7"
version: "1.1.8"
mime:
dependency: transitive
description:

@ -1,6 +1,6 @@
name: jpush_flutter
description: Offically supported JPush Flutter plugin.
version: 0.3.0
description: JIGUANG officially supported JPush Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件Android & iOS(https://www.jiguang.cn)。
version: 0.5.0
author: xudong.rao <xudong.rao@outlook.com>
homepage: https://www.jiguang.cn

Loading…
Cancel
Save