|
|
|
@ -25,26 +25,7 @@ final JPush jpush = new JPush();
|
|
|
|
|
String platformVersion;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Platform messages may fail, so we use a try/catch PlatformException.
|
|
|
|
|
jpush.getRegistrationID().then((rid) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "flutter getRegistrationID: $rid";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jpush.setup(
|
|
|
|
|
appKey: "a1703c14b186a68a66ef86c1",
|
|
|
|
|
channel: "theChannel",
|
|
|
|
|
production: false,
|
|
|
|
|
debug: true,
|
|
|
|
|
);
|
|
|
|
|
jpush.applyPushAuthority(new NotificationSettingsIOS(
|
|
|
|
|
sound: true,
|
|
|
|
|
alert: true,
|
|
|
|
|
badge: true));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
jpush.addEventHandler(
|
|
|
|
|
onReceiveNotification: (Map<String, dynamic> message) async {
|
|
|
|
|
print("flutter onReceiveNotification: $message");
|
|
|
|
@ -70,6 +51,28 @@ final JPush jpush = new JPush();
|
|
|
|
|
platformVersion = 'Failed to get platform version.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jpush.setup(
|
|
|
|
|
appKey: "你自己应用的 AppKey",
|
|
|
|
|
channel: "theChannel",
|
|
|
|
|
production: false,
|
|
|
|
|
debug: 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) {
|
|
|
|
|
print("flutter get registration id : $rid");
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "flutter getRegistrationID: $rid";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
@ -94,9 +97,11 @@ final JPush jpush = new JPush();
|
|
|
|
|
child: new Column(
|
|
|
|
|
children:[
|
|
|
|
|
new Text('result: $debugLable\n'),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('sendLocalNotification\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "sendLocalNotification", onPressed: (){
|
|
|
|
|
// 三秒后出发本地推送
|
|
|
|
|
var fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000);
|
|
|
|
|
var localNotification = LocalNotification(
|
|
|
|
@ -114,12 +119,9 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = res;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('getLaunchAppNotification\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "getLaunchAppNotification", onPressed: (){
|
|
|
|
|
jpush.getLaunchAppNotification().then((map) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "getLaunchAppNotification success: $map";
|
|
|
|
@ -130,16 +132,13 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "getLaunchAppNotification error: $error";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('applyPushAuthority\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
jpush.applyPushAuthority(NotificationSettingsIOS(badge: true, alert: true, sound: true));
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('setTags\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
]),
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "setTags", onPressed: (){
|
|
|
|
|
jpush.setTags(["lala","haha"]).then((map) {
|
|
|
|
|
var tags = map['tags'];
|
|
|
|
|
setState(() {
|
|
|
|
@ -152,42 +151,21 @@ final JPush jpush = new JPush();
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('cleanTags\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
jpush.cleanTags().then((map) {
|
|
|
|
|
var tags = map['tags'];
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "cleanTags success: $map $tags";
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "cleanTags error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('addTags\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "addTags", onPressed: (){
|
|
|
|
|
jpush.addTags(["lala","haha"]).then((map) {
|
|
|
|
|
var tags = map['tags'];
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "addTags success: $map $tags";
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catchError((error) {
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "addTags error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('deleteTags\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "deleteTags", onPressed: (){
|
|
|
|
|
jpush.deleteTags(["lala","haha"]).then((map) {
|
|
|
|
|
var tags = map['tags'];
|
|
|
|
|
setState(() {
|
|
|
|
@ -199,12 +177,14 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "deleteTags error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('getAllTags\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "getAllTags", onPressed: (){
|
|
|
|
|
jpush.getAllTags().then((map) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "getAllTags success: $map";
|
|
|
|
@ -215,12 +195,28 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "getAllTags error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('setAlias\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "cleanTags", onPressed: (){
|
|
|
|
|
jpush.cleanTags().then((map) {
|
|
|
|
|
var tags = map['tags'];
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "cleanTags success: $map $tags";
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catchError((error) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "cleanTags error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "setAlias", onPressed: (){
|
|
|
|
|
jpush.setAlias("thealias11").then((map) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "setAlias success: $map";
|
|
|
|
@ -231,12 +227,9 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "setAlias error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('deleteAlias\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "deleteAlias", onPressed: (){
|
|
|
|
|
jpush.deleteAlias().then((map) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "deleteAlias success: $map";
|
|
|
|
@ -247,12 +240,32 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "deleteAlias error: $error";
|
|
|
|
|
});
|
|
|
|
|
}) ;
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('setBadge\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "stopPush",onPressed: (){
|
|
|
|
|
jpush.stopPush();
|
|
|
|
|
}),
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "resumePush", onPressed: (){
|
|
|
|
|
jpush.resumePush();
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
new Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "clearAllNotifications",onPressed: (){
|
|
|
|
|
jpush.clearAllNotifications();
|
|
|
|
|
}),
|
|
|
|
|
new Text(" "),
|
|
|
|
|
new CustomButton(title: "setBadge", onPressed: (){
|
|
|
|
|
jpush.setBadge(66).then((map) {
|
|
|
|
|
setState(() {
|
|
|
|
|
debugLable = "setBadge success: $map";
|
|
|
|
@ -263,36 +276,34 @@ final JPush jpush = new JPush();
|
|
|
|
|
debugLable = "setBadge error: $error";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('stopPush\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
jpush.stopPush();
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('resumePush\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
jpush.resumePush();
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
new FlatButton(
|
|
|
|
|
child: new Text('clearAllNotifications\n'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
jpush.clearAllNotifications();
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// 封装控件
|
|
|
|
|
class CustomButton extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
|
|
const CustomButton({@required this.onPressed, @required this.title});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return new FlatButton(
|
|
|
|
|
onPressed: onPressed,
|
|
|
|
|
child: new Text("$title"),
|
|
|
|
|
color: Color(0xff585858),
|
|
|
|
|
highlightColor: Color(0xff888888),
|
|
|
|
|
splashColor: Color(0xff888888),
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
//padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|