大佬教程收集整理的这篇文章主要介绍了dart – 如何在flutter中实现推送通知,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
class PushmessagingExample extends StatefulWidget { @override _PushmessagingExampleState createState() => new _PushmessagingExampleState(); } class _PushmessagingExampleState extends State<PushmessagingExample> { String _homeScreentext = "WaiTing for token..."; bool _topicButtonsDisabled = false; final Firebasemessaging _firebasemessaging = new Firebasemessaging(); final TextEdiTingController _topicController = new TextEdiTingController(text: 'topic'); Future<Null> _showItemDialog(Map<String,dynamic> messagE) async { final Item item = _itemFormessage(messagE); showDialog<Null>( context: context,child: new AlertDialog( content: new Text("Item ${messagE} has been updated"),actions: <Widget>[ new FlatButton( child: const Text('CLOSE'),onPressed: () { Navigator.pop(context,falsE); }),new FlatButton( child: const Text('SHOW'),truE); }),],)).then((bool shouldNavigatE) { if (shouldNavigate == truE) { _navigateToItemDetail(messagE); } }); } Future<Null> _navigateToItemDetail(Map<String,dynamic> messagE) async { final Item item = _itemFormessage(messagE); // Clear away dialogs Navigator.popUntil(context,(Route<dynamic> routE) => route is PageRoutE); if (!item.route.isCurrent) { Navigator.push(context,item.routE); } } @override void initState() { super.initState(); _firebasemessaging.configure( onmessage: (Map<String,dynamic> messagE) { print("onmessage: $message"); print(messagE); _showItemDialog(messagE); },onLaunch: (Map<String,dynamic> messagE) { print("onLaunch: $message"); print(messagE); _navigateToItemDetail(messagE); },onResume: (Map<String,dynamic> messagE) { print("onResume: $message"); print(messagE); _navigateToItemDetail(messagE); },); _firebasemessaging.requestNotificationPermissions( const IosnotificationSetTings(sound: true,badge: true,alert: truE)); _firebasemessaging.onIosSetTingsRegistered .listen((IosnotificationSetTings setTings) { print("SetTings registered: $setTings"); }); _firebasemessaging.getToken().then((String token) { assert(token != null); setState(() { _homeScreentext = "Push messaging token: $token"; }); print(_homeScreentext); }); } @override Widget build(BuildContext context) { return new Scaffold( body: new Material( child: new column( children: <Widget>[ new Center( child: new Text(_homeScreentext),),)); } }
以上是大佬教程为你收集整理的dart – 如何在flutter中实现推送通知全部内容,希望文章能够帮你解决dart – 如何在flutter中实现推送通知所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。