Guest User

Untitled

a guest
Oct 21st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. ionic cordova plugin add cordova-plugin-local-notification
  2. npm install --save @ionic-native/local-notifications
  3.  
  4. let year = new Date().getFullYear();
  5. let month = new Date().getMonth();
  6. let day = new Date().getDate();
  7.  
  8. let time1 = new Date(year, month, day, 10, 00, 0, 0);
  9. let time2 = new Date(year, month, day, 12, 00, 0, 0);
  10.  
  11. this.localNotifications.schedule([
  12. {
  13. id: 1,
  14. title: 'My first notification',
  15. text: 'First notification test one',
  16. trigger: { at: new Date(time1) },
  17. data: {"id": 1, "name": "Mr. A"}
  18. },
  19. {
  20. id: 2,
  21. title: 'My Second notification',
  22. text: 'Second notification on 12 pm',
  23. trigger: { at: new Date(time2) },
  24. data: {"id": 2, "name": "Mr. B"}
  25. }
  26. ]);
  27.  
  28. let year = new Date().getFullYear();
  29. let month = new Date().getMonth();
  30. let day = new Date().getDate();
  31.  
  32. let time1 = new Date(year, month, day, 10, 00, 0, 0);
  33. let time2 = new Date(year, month, day, 12, 00, 0, 0);
  34.  
  35. this.localNotifications.schedule([
  36. {
  37. id: 1,
  38. title: 'My first notification',
  39. text: 'First notification test one',
  40. firstAt: new Date(time1),
  41. every: 24*60,
  42. data: {"id": 1, "name": "Mr. A"}
  43. },
  44. {
  45. id: 2,
  46. title: 'My Second notification',
  47. text: 'Second notification on 12 pm',
  48. firstAt: new Date(time2),
  49. every: 24*60,
  50. data: {"id": 2, "name": "Mr. B"}
  51. }
  52. ]);
  53.  
  54. this.localNotifications.schedule({
  55. text: 'Delayed ILocalNotification',
  56. trigger: {at: new Date(new Date().getTime() + 3600)},
  57. led: 'FF0000',
  58. sound: null});
  59.  
  60. let year = new Date().getFullYear();
  61. let month = new Date().getMonth();
  62. let day = new Date().getDate();
  63.  
  64. let time1 = new Date(year, month, day, 10, 00, 0, 0);
  65. let time2 = new Date(year, month, day, 12, 00, 0, 0);
  66.  
  67. this.localNotifications.schedule([
  68. {
  69. id: 1,
  70. title: 'My first notification',
  71. text: 'First notification test one',
  72. trigger: {firstAt: new Date(time1)},
  73. every: every: "day"
  74. data: {"id": 1, "name": "Mr. A"}
  75. },
  76. {
  77. id: 2,
  78. title: 'My Second notification',
  79. text: 'Second notification on 12 pm',
  80. trigger: {firstAt: new Date(time2)},
  81. every: "day", //"day","hour","minute","week" can be used
  82. data: {"id": 2, "name": "Mr. B"}
  83. }
  84. ]);
Add Comment
Please, Sign In to add comment