Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ionic cordova plugin add cordova-plugin-local-notification
- npm install --save @ionic-native/local-notifications
- let year = new Date().getFullYear();
- let month = new Date().getMonth();
- let day = new Date().getDate();
- let time1 = new Date(year, month, day, 10, 00, 0, 0);
- let time2 = new Date(year, month, day, 12, 00, 0, 0);
- this.localNotifications.schedule([
- {
- id: 1,
- title: 'My first notification',
- text: 'First notification test one',
- trigger: { at: new Date(time1) },
- data: {"id": 1, "name": "Mr. A"}
- },
- {
- id: 2,
- title: 'My Second notification',
- text: 'Second notification on 12 pm',
- trigger: { at: new Date(time2) },
- data: {"id": 2, "name": "Mr. B"}
- }
- ]);
- let year = new Date().getFullYear();
- let month = new Date().getMonth();
- let day = new Date().getDate();
- let time1 = new Date(year, month, day, 10, 00, 0, 0);
- let time2 = new Date(year, month, day, 12, 00, 0, 0);
- this.localNotifications.schedule([
- {
- id: 1,
- title: 'My first notification',
- text: 'First notification test one',
- firstAt: new Date(time1),
- every: 24*60,
- data: {"id": 1, "name": "Mr. A"}
- },
- {
- id: 2,
- title: 'My Second notification',
- text: 'Second notification on 12 pm',
- firstAt: new Date(time2),
- every: 24*60,
- data: {"id": 2, "name": "Mr. B"}
- }
- ]);
- this.localNotifications.schedule({
- text: 'Delayed ILocalNotification',
- trigger: {at: new Date(new Date().getTime() + 3600)},
- led: 'FF0000',
- sound: null});
- let year = new Date().getFullYear();
- let month = new Date().getMonth();
- let day = new Date().getDate();
- let time1 = new Date(year, month, day, 10, 00, 0, 0);
- let time2 = new Date(year, month, day, 12, 00, 0, 0);
- this.localNotifications.schedule([
- {
- id: 1,
- title: 'My first notification',
- text: 'First notification test one',
- trigger: {firstAt: new Date(time1)},
- every: every: "day"
- data: {"id": 1, "name": "Mr. A"}
- },
- {
- id: 2,
- title: 'My Second notification',
- text: 'Second notification on 12 pm',
- trigger: {firstAt: new Date(time2)},
- every: "day", //"day","hour","minute","week" can be used
- data: {"id": 2, "name": "Mr. B"}
- }
- ]);
Add Comment
Please, Sign In to add comment