Guest User

Untitled

a guest
Jan 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. _firebaseMessaging.configure(
  2. onMessage: (Map<String, dynamic> message) {
  3. print('on message $message');
  4. print(message['route']);
  5. globals.firebaseIn(message['route']);
  6. },
  7. onResume: (Map<String, dynamic> message) {
  8. print('on resume $message');
  9. globals.firebaseOut(message['route']);
  10. },
  11. onLaunch: (Map<String, dynamic> message) {
  12. print('on launch $message');
  13. globals.firebaseOut(message['route']);
  14. },
  15. );
  16.  
  17. void firebaseIn(String route) {
  18. showNotificationWithDefaultSound(route);
  19. }
  20.  
  21. Future onSelectNotification(String payload) async {
  22. router.navigateTo(currentContext, payload,
  23. transition: TransitionType.inFromRight,
  24. transitionDuration: const Duration(milliseconds: 500));
  25. }
  26.  
  27. Future showNotificationWithDefaultSound(String route) async {
  28. var androidPlatformChannelSpecifics = new
  29. AndroidNotificationDetails(
  30. 'your channel id', 'your channel name', 'your channel description',
  31. importance: Importance.Max, priority: Priority.High);
  32. var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
  33. var platformChannelSpecifics = new NotificationDetails(
  34. androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
  35. await flutterLocalNotificationsPlugin.show(
  36. 0,
  37. 'استطلاع جديد',
  38. 'لديك استطلاع جديد',
  39. platformChannelSpecifics,
  40. payload: route,
  41. );
  42. }
  43.  
  44. void firebaseOut(String route) {
  45. router.navigateTo(currentContext, route,
  46. transition: TransitionType.inFromRight,
  47. transitionDuration: const Duration(milliseconds: 500));
  48. }
Add Comment
Please, Sign In to add comment