flutter_umeng_push 0.0.3 flutter_umeng_push: ^0.0.3 copied to clipboard
A new Flutter plugin for Android to use umeng push.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_umeng_push/flutter_umeng_push.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final FlutterUmengPush _flutterUmpush = new FlutterUmengPush();
@override
void initState() {
super.initState();
initPushState();
}
Future<void> initPushState() async {
_flutterUmpush.configure(
onReceiveMessage: (String message) async{
print("main onReceiveMessage: $message");
setState(() {
_platformVersion = "收到消息:$message";
});
},
onMessage: (String message) async {
print("main onMessage: $message");
setState(() {
_platformVersion = message;
});
return true;
},
onLaunch: (String message) async {
print("main onLaunch: $message");
setState(() {
_platformVersion = message;
});
return true;
},
onResume: (String message) async {
print("main onResume: $message");
setState(() {
_platformVersion = message;
});
return true;
},
onToken: (String token) async {
print("main onToken: $token");
setState(() {
_platformVersion = token;
});
return true;
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}