flutter_push_mixin 1.4.0 flutter_push_mixin: ^1.4.0 copied to clipboard
flutter 中国主要平台混合推送(xiaomi、huawei、vivo、oppo、apple)
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_push_mixin/flutter_push_mixin.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initPushUtil();
}
Future initPushUtil() async {
FlutterPushMixin.initMixinPushListen(
onAndroidGetId: (RegIdModel model) {},
onMessage: (PayloadMessageModel model) {},
getApnsToken: (String token) {
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '推送数据获取测试',
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: CupertinoButton(
color: Colors.red,
onPressed: () {
initPushUtil();
},
child: const Text('获取RegId并复制'),
)),
),
);
}
}