update to 0.0.5

master
huangminlinux 6 years ago
parent 4e0cf44414
commit d0a80076a6

@ -1,8 +1,56 @@
# Generated by pub on 2018-09-29 10:15:14.625856.
# Generated by pub on 2018-10-08 23:40:55.475551.
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/
boolean_selector:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
charcode:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
collection:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
convert:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.0.2/lib/
crypto:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.0.6/lib/
csslib:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/csslib-0.14.6/lib/
flutter:file:///Applications/flutter/packages/flutter/lib/
front_end:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.6/lib/
glob:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/glob-1.1.7/lib/
html:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.13.3+3/lib/
http:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0/lib/
http_multi_server:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.0.5/lib/
http_parser:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/
io:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/io-0.3.3/lib/
js:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/
json_rpc_2:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/json_rpc_2-2.0.9/lib/
kernel:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.6/lib/
logging:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib/
matcher:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib/
meta:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
mime:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/mime-0.9.6+2/lib/
mockito:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-3.0.0/lib/
multi_server_socket:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/multi_server_socket-1.0.2/lib/
node_preamble:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/node_preamble-1.4.4/lib/
package_config:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-1.0.5/lib/
package_resolver:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/package_resolver-1.0.6/lib/
path:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib/
platform:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/platform-2.2.0/lib/
plugin:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/plugin-0.2.0+3/lib/
pool:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.3.6/lib/
pub_semver:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.4.2/lib/
shelf:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.3+3/lib/
shelf_packages_handler:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-1.0.4/lib/
shelf_static:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.8/lib/
shelf_web_socket:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.2+4/lib/
sky_engine:file:///Applications/flutter/bin/cache/pkg/sky_engine/lib/
source_map_stack_trace:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/source_map_stack_trace-1.1.5/lib/
source_maps:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/source_maps-0.10.8/lib/
source_span:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.4.1/lib/
stack_trace:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib/
string_scanner:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/
term_glyph:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.0.1/lib/
test:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/test-1.3.4/lib/
typed_data:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
utf:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/utf-0.9.0+5/lib/
vector_math:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
vm_service_client:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/vm_service_client-0.2.6/lib/
watcher:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+10/lib/
web_socket_channel:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.0.9/lib/
yaml:file:///Applications/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/
jpush_flutter:lib/

@ -7,7 +7,7 @@
```yaml
dependencies:
jpush_flutter: 0.0.3
jpush_flutter: 0.0.5
```
### 配置

@ -28,7 +28,8 @@
添加事件监听方法。
```dart
JPush.addEventHandler(
JPush jpush = new JPush();
jpush.addEventHandler(
// 接收通知回调方法。
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
@ -52,7 +53,8 @@ JPush.addEventHandler(
- 将缓存的事件下发到 dart 环境中。
```dart
JPush.setup(
JPush jpush = new JPush();
jpush.setup(
appKey: "替换成你自己的 appKey",
channel: "theChannel",
production: false
@ -64,7 +66,8 @@ JPush.setup(
获取 registrationId这个 JPush 运行通过 registrationId 来进行推送.
```dart
JPush.getRegistrationID().then((rid) { });
JPush jpush = new JPush();
jpush.getRegistrationID().then((rid) { });
```
#### stopPush
@ -72,7 +75,8 @@ JPush.getRegistrationID().then((rid) { });
停止推送功能,调用该方法将不会接收到通知。
```dart
JPush.stopPush();
JPush jpush = new JPush();
jpush.stopPush();
```
#### resumePush
@ -80,7 +84,8 @@ JPush.stopPush();
调用 stopPush 后,可以通过 resumePush 方法恢复推送。
```dart
JPush.resumePush();
JPush jpush = new JPush();
jpush.resumePush();
```
#### setAlias
@ -88,7 +93,8 @@ JPush.resumePush();
设置别名,极光后台可以通过别名来推送,一个 App 应用只有一个别名,一般用来存储用户 id。
```
JPush.setAlias("your alias").then((map) { });
JPush jpush = new JPush();
jpush.setAlias("your alias").then((map) { });
```
#### deleteAlias
@ -96,7 +102,8 @@ JPush.setAlias("your alias").then((map) { });
可以通过 deleteAlias 方法来删除已经设置的 alias。
```dart
JPush.deleteAlias().then((map) {})
JPush jpush = new JPush();
jpush.deleteAlias().then((map) {})
```
#### addTags
@ -104,7 +111,8 @@ JPush.deleteAlias().then((map) {})
在原来的 Tags 列表上添加指定 tags。
```
JPush.addTags(["tag1","tag2"]).then((map) {});
JPush jpush = new JPush();
jpush.addTags(["tag1","tag2"]).then((map) {});
```
#### deleteTags
@ -112,15 +120,17 @@ JPush.addTags(["tag1","tag2"]).then((map) {});
在原来的 Tags 列表上删除指定 tags。
```
JPush.deleteTags(["tag1","tag2"]).then((map) {});
JPush jpush = new JPush();
jpush.deleteTags(["tag1","tag2"]).then((map) {});
```
#### setTags
重置 tags。
```
JPush.setTags(["tag1","tag2"]).then((map) {});
```dart
JPush jpush = new JPush();
jpush.setTags(["tag1","tag2"]).then((map) {});
```
#### cleanTags
@ -128,15 +138,16 @@ JPush.setTags(["tag1","tag2"]).then((map) {});
清空所有 tags
```dart
JPush.setTags().then((map) {});
jpush.setTags().then((map) {});
```
#### getAllTags
获取当前 tags 列表。
```
JPush.getAllTags().then((map) {});
```dart
JPush jpush = new JPush();
jpush.getAllTags().then((map) {});
```
#### sendLocalNotification
@ -145,6 +156,7 @@ JPush.getAllTags().then((map) {});
```dart
// 延时 3 秒后触发本地通知。
JPush jpush = new JPush();
var fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000);
var localNotification = LocalNotification(
id: 234,
@ -156,7 +168,7 @@ var localNotification = LocalNotification(
badge: 5, // 该参数只有在 iOS 有效
extras: {"fa": "0"} // 设置 extras extras 需要是 Map<String, String>
);
JPush.sendLocalNotification(localNotification).then((res) {});
jpush.sendLocalNotification(localNotification).then((res) {});
```
#### clearAllNotifications
@ -164,7 +176,8 @@ JPush.sendLocalNotification(localNotification).then((res) {});
清楚通知栏上所有通知。
```dart
JPush.clearAllNotifications();
JPush jpush = new JPush();
jpush.clearAllNotifications();
```
#### applyPushAuthority
@ -174,7 +187,8 @@ JPush.clearAllNotifications();
**注意: iOS10+ 可以通过该方法来设置推送是否前台展示,是否触发声音,是否设置应用角标 badge**
```dart
JPush.applyPushAuthority(new NotificationSettingsIOS(
JPush jpush = new JPush();
jpush.applyPushAuthority(new NotificationSettingsIOS(
sound: true,
alert: true,
badge: true));
@ -187,7 +201,8 @@ JPush.applyPushAuthority(new NotificationSettingsIOS(
设置应用 badge 值,该方法还会同步 JPush 服务器的的 badge 值JPush 服务器的 badge 值用于推送 badge 自动 +1 时会用到。
```dart
JPush.setBadge(66).then((map) {});
JPush jpush = new JPush();
jpush.setBadge(66).then((map) {});
```
### getLaunchAppNotification
@ -195,6 +210,7 @@ JPush.setBadge(66).then((map) {});
获取 iOS 点击推送启动应用的那条通知。
```dart
JPush.getLaunchAppNotification().then((map) {});
JPush jpush = new JPush();
jpush.getLaunchAppNotification().then((map) {});
```

@ -13,7 +13,7 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
String debugLable = 'Unknown';
final JPush jpush = new JPush();
@override
void initState() {
super.initState();
@ -23,26 +23,28 @@ class _MyAppState extends State<MyApp> {
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
JPush.getRegistrationID().then((rid) {
jpush.getRegistrationID().then((rid) {
setState(() {
debugLable = "flutter getRegistrationID: $rid";
});
});
JPush.setup(
jpush.setup(
appKey: "a1703c14b186a68a66ef86c1",
channel: "theChannel",
production: false
);
JPush.applyPushAuthority(new NotificationSettingsIOS(
jpush.applyPushAuthority(new NotificationSettingsIOS(
sound: false,
alert: false,
badge: false));
try {
JPush.addEventHandler(
jpush.addEventHandler(
onReceiveNotification: (Map<String, dynamic> message) async {
// print("flutter onReceiveNotification: $message");
// setState(() {
@ -102,9 +104,9 @@ class _MyAppState extends State<MyApp> {
fireTime: fireDate,
subtitle: 'fasf',
badge: 5,
extras: {"fa": 0}
extras: {"fa": "0"}
);
JPush.sendLocalNotification(localNotification).then((res) {
jpush.sendLocalNotification(localNotification).then((res) {
setState(() {
debugLable = res;
});
@ -115,12 +117,12 @@ class _MyAppState extends State<MyApp> {
new FlatButton(
child: new Text('applyPushAuthority\n'),
onPressed: () {
JPush.applyPushAuthority(NotificationSettingsIOS(badge: true, alert: true, sound: true));
jpush.applyPushAuthority(NotificationSettingsIOS(badge: true, alert: true, sound: true));
}),
new FlatButton(
child: new Text('setTags\n'),
onPressed: () {
JPush.setTags(["lala","haha"]).then((map) {
jpush.setTags(["lala","haha"]).then((map) {
var tags = map['tags'];
setState(() {
debugLable = "set tags success: $map $tags";
@ -135,7 +137,7 @@ class _MyAppState extends State<MyApp> {
new FlatButton(
child: new Text('cleanTags\n'),
onPressed: () {
JPush.cleanTags().then((map) {
jpush.cleanTags().then((map) {
var tags = map['tags'];
setState(() {
debugLable = "cleanTags success: $map $tags";
@ -151,7 +153,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('addTags\n'),
onPressed: () {
JPush.addTags(["lala","haha"]).then((map) {
jpush.addTags(["lala","haha"]).then((map) {
var tags = map['tags'];
setState(() {
debugLable = "addTags success: $map $tags";
@ -168,7 +170,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('deleteTags\n'),
onPressed: () {
JPush.deleteTags(["lala","haha"]).then((map) {
jpush.deleteTags(["lala","haha"]).then((map) {
var tags = map['tags'];
setState(() {
debugLable = "deleteTags success: $map $tags";
@ -185,7 +187,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('getAllTags\n'),
onPressed: () {
JPush.getAllTags().then((map) {
jpush.getAllTags().then((map) {
setState(() {
debugLable = "getAllTags success: $map";
});
@ -201,7 +203,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('setAlias\n'),
onPressed: () {
JPush.setAlias("thealias11").then((map) {
jpush.setAlias("thealias11").then((map) {
setState(() {
debugLable = "setAlias success: $map";
});
@ -217,7 +219,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('deleteAlias\n'),
onPressed: () {
JPush.deleteAlias().then((map) {
jpush.deleteAlias().then((map) {
setState(() {
debugLable = "deleteAlias success: $map";
});
@ -233,7 +235,7 @@ class _MyAppState extends State<MyApp> {
child: new Text('setBadge\n'),
onPressed: () {
JPush.setBadge(66).then((map) {
jpush.setBadge(66).then((map) {
setState(() {
debugLable = "setBadge success: $map";
});
@ -249,28 +251,28 @@ class _MyAppState extends State<MyApp> {
child: new Text('stopPush\n'),
onPressed: () {
JPush.stopPush();
jpush.stopPush();
}),
new FlatButton(
child: new Text('resumePush\n'),
onPressed: () {
JPush.resumePush();
jpush.resumePush();
}),
new FlatButton(
child: new Text('clearAllNotifications\n'),
onPressed: () {
JPush.clearAllNotifications();
jpush.clearAllNotifications();
}),
new FlatButton(
child: new Text('getLaunchAppNotification\n'),
onPressed: () {
JPush.getLaunchAppNotification().then((map) {
jpush.getLaunchAppNotification().then((map) {
setState(() {
debugLable = "getLaunchAppNotification success: $map";
});

@ -136,7 +136,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.3"
version: "0.0.5"
js:
dependency: transitive
description:
@ -186,6 +186,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+2"
mockito:
dependency: "direct dev"
description:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
multi_server_socket:
dependency: transitive
description:
@ -221,6 +228,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
plugin:
dependency: transitive
description:
@ -332,7 +346,7 @@ packages:
source: hosted
version: "1.0.1"
test:
dependency: transitive
dependency: "direct dev"
description:
name: test
url: "https://pub.dartlang.org"

@ -21,6 +21,8 @@ dependencies:
cupertino_icons: ^0.1.2
dev_dependencies:
test: ^1.3.0
mockito: ^3.0.0
flutter_test:
sdk: flutter

@ -6,8 +6,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:jpush_example/main.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:test/test.dart';
void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
@ -15,11 +19,35 @@ void main() {
await tester.pumpWidget(new MyApp());
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) =>
widget is Text && widget.data.startsWith('Running on:'),
),
findsOneWidget);
// expect(
// find.byWidgetPredicate(
// (Widget widget) =>
// widget is Text && widget.data.startsWith('Running on:'),
// ),
// findsOneWidget);
});
MockMethodChannel mockChannel;
JPush.setup(
appKey: "a1703c14b186a68a66ef86c1",
channel: "theChannel",
production: false
);
test('requestNotificationPermissions on ios with custom permissions', () {
JPush.applyPushAuthority(new NotificationSettingsIOS(
sound: false,
alert: false,
badge: false));
// firebaseMessaging.requestNotificationPermissions(
// const IosNotificationSettings(sound: false));
verify(mockChannel.invokeMethod('requestNotificationPermissions',
<String, bool>{'sound': false, 'badge': true, 'alert': true}));
});
}

@ -1,25 +1,31 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'dart:io' show Platform;
import 'package:platform/platform.dart';
typedef Future<dynamic> EventHandler(Map<String, dynamic> event);
class JPush {
static const MethodChannel _channel =
const MethodChannel('jpush');
factory JPush() => _instance;
static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
final MethodChannel _channel;
final Platform _platform;
@visibleForTesting
JPush.private(MethodChannel channel, Platform platform)
: _channel = channel,
_platform = platform;
static final JPush _instance = new JPush.private(
const MethodChannel('jpush'),
const LocalPlatform());
static EventHandler _onReceiveNotification;
static EventHandler _onOpenNotification;
static EventHandler _onReceiveMessage;
EventHandler _onReceiveNotification;
EventHandler _onOpenNotification;
EventHandler _onReceiveMessage;
static void setup({
void setup({
String appKey,
String channel,
bool production,
@ -29,7 +35,7 @@ class JPush {
///
/// JPush ()
///
static void addEventHandler({
void addEventHandler({
EventHandler onReceiveNotification,
EventHandler onOpenNotification,
EventHandler onReceiveMessage,
@ -40,7 +46,7 @@ class JPush {
_channel.setMethodCallHandler(_handleMethod);
}
static Future<Null> _handleMethod(MethodCall call) async {
Future<Null> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onReceiveNotification":
return _onReceiveNotification(call.arguments.cast<String, dynamic>());
@ -56,9 +62,9 @@ class JPush {
///
///
///
static void applyPushAuthority([NotificationSettingsIOS iosSettings = const NotificationSettingsIOS()]) {
void applyPushAuthority([NotificationSettingsIOS iosSettings = const NotificationSettingsIOS()]) {
if (!Platform.isIOS) {
if (!_platform.isIOS) {
return;
}
@ -72,7 +78,7 @@ class JPush {
/// @param {Function} success = ({"tags":[String]}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> setTags(List<String> tags) async {
Future<Map<dynamic, dynamic>> setTags(List<String> tags) async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('setTags', tags);
return result;
}
@ -83,7 +89,7 @@ class JPush {
/// @param {Function} success = ({"tags":[String]}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> cleanTags() async {
Future<Map<dynamic, dynamic>> cleanTags() async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('cleanTags');
return result;
}
@ -96,7 +102,7 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> addTags(List<String> tags) async {
Future<Map<dynamic, dynamic>> addTags(List<String> tags) async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('addTags', tags);
return result;
}
@ -108,7 +114,7 @@ class JPush {
/// @param {Function} success = ({"tags":[String]}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> deleteTags(List<String> tags) async {
Future<Map<dynamic, dynamic>> deleteTags(List<String> tags) async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('deleteTags', tags);
return result;
}
@ -119,7 +125,7 @@ class JPush {
/// @param {Function} success = ({"tags":[String]}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> getAllTags() async {
Future<Map<dynamic, dynamic>> getAllTags() async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('getAllTags');
return result;
}
@ -132,7 +138,7 @@ class JPush {
/// @param {Function} success = ({"alias":String}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> setAlias(String alias) async {
Future<Map<dynamic, dynamic>> setAlias(String alias) async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('setAlias', alias);
return result;
}
@ -143,7 +149,7 @@ class JPush {
/// @param {Function} success = ({"alias":String}) => { }
/// @param {Function} fail = ({"errorCode":int}) => { }
///
static Future<Map<dynamic, dynamic>> deleteAlias() async {
Future<Map<dynamic, dynamic>> deleteAlias() async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('deleteAlias');
return result;
}
@ -154,28 +160,28 @@ class JPush {
///
/// @param {Int} badge
///
static Future setBadge(int badge) async {
Future setBadge(int badge) async {
await _channel.invokeMethod('setBadge', badge);
}
///
/// resumePush
///
static Future stopPush() async {
Future stopPush() async {
await _channel.invokeMethod('stopPush');
}
///
///
///
static Future resumePush() async {
Future resumePush() async {
await _channel.invokeMethod('resumePush');
}
///
///
///
static Future clearAllNotifications() async {
Future clearAllNotifications() async {
await _channel.invokeMethod('clearAllNotifications');
}
@ -186,7 +192,7 @@ class JPush {
/// icon notification @{}
/// @param {Function} callback = (Object) => {}
///
static Future<Map<dynamic, dynamic>> getLaunchAppNotification() async {
Future<Map<dynamic, dynamic>> getLaunchAppNotification() async {
final Map<dynamic, dynamic> result = await _channel.invokeMethod('getLaunchAppNotification');
return result;
}
@ -196,7 +202,7 @@ class JPush {
///
/// @param {Function} callback = (String) => {}
///
static Future<String> getRegistrationID() async {
Future<String> getRegistrationID() async {
final String rid = await _channel.invokeMethod('getRegistrationID');
return rid;
}
@ -205,7 +211,7 @@ class JPush {
///
/// @param {Notification} notification
///
static Future<String> sendLocalNotification(LocalNotification notification) async {
Future<String> sendLocalNotification(LocalNotification notification) async {
await _channel.invokeMethod('sendLocalNotification', notification.toMap());
return notification.toMap().toString();

@ -1,6 +1,41 @@
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
packages:
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.33.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
@ -8,11 +43,116 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.6"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
front_end:
dependency: transitive
description:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.6"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3+3"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
json_rpc_2:
dependency: transitive
description:
name: json_rpc_2
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.6"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.3+2"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.3+1"
meta:
dependency: transitive
description:
@ -20,11 +160,172 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+2"
mockito:
dependency: "direct dev"
description:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
multi_server_socket:
dependency: transitive
description:
name: multi_server_socket
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
node_preamble:
dependency: transitive
description:
name: node_preamble
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.4"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
package_resolver:
dependency: transitive
description:
name: package_resolver
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
platform:
dependency: "direct main"
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
plugin:
dependency: transitive
description:
name: plugin
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+3"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.6"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.2"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.3+3"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
shelf_static:
dependency: transitive
description:
name: shelf_static
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.8"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.2+4"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.5"
source_maps:
dependency: transitive
description:
name: source_maps
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.8"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.8"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
test:
dependency: "direct dev"
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.4"
typed_data:
dependency: transitive
description:
@ -32,6 +333,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
utf:
dependency: transitive
description:
name: utf
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0+5"
vector_math:
dependency: transitive
description:
@ -39,5 +347,33 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
vm_service_client:
dependency: transitive
description:
name: vm_service_client
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.6"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+10"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.9"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.15"
sdks:
dart: ">=2.0.0-dev.68.0 <3.0.0"
dart: ">=2.0.0 <3.0.0"

@ -1,6 +1,6 @@
name: jpush_flutter
description: Offically supported JPush Flutter plugin.
version: 0.0.3
version: 0.0.5
author: huminios <h380108184@gmail.com>
homepage: https://www.jiguang.cn
@ -8,9 +8,13 @@ environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
platform: ^2.0.0
flutter:
sdk: flutter
dev_dependencies:
test: ^1.3.0
mockito: ^3.0.0
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

@ -0,0 +1,88 @@
import 'package:flutter/services.dart';
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:test/test.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
void main() {
MockMethodChannel mockChannel;
JPush jpush;
setUp(() {
mockChannel = new MockMethodChannel();
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
});
jpush.setup(
appKey: "a1703c14b186a68a66ef86c1",
channel: "theChannel",
production: false
);
test('applyPushAuthority on ios with params', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.applyPushAuthority(new NotificationSettingsIOS(
sound: true,
alert: true,
badge: true));
verify(mockChannel.invokeMethod('applyPushAuthority',
<String, bool>{'sound': true, 'badge': true, 'alert': true}));
});
test('addEventHandler', () {
// TODO:
});
test('setAlias', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.setAlias('alias').then((map) {
expect(map, contains('alias'));
}).catchError((error) {});
});
test('deleteAlias', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.deleteAlias().then((map) {
expect(map, contains('alias'));
}).catchError((error) {});
});
test('deleteAlias', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.deleteAlias().then((map) {
expect(map, contains('alias'));
}).catchError((error) {});
});
test('addTags', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.addTags(["tag1","tag2"]).then((map) {
expect(map, contains('tags'));
}).catchError((error) {});
});
test('deleteTags', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.deleteTags(["tag1","tag2"]).then((map) {
expect(map, contains('tags'));
}).catchError((error) {});
});
test('setTags', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.setTags(["tag1","tag2"]).then((map) {
expect(map, contains('tags'));
}).catchError((error) {});
});
test('getAllTags', () {
jpush = new JPush.private(mockChannel, FakePlatform(operatingSystem: 'ios'));
jpush.getAllTags().then((map) {
expect(map, contains('tags'));
}).catchError((error) {});
});
}
class MockMethodChannel extends Mock implements MethodChannel {}
Loading…
Cancel
Save