diff --git a/android/app/src/main/res/drawable/large_icon_sample.png b/android/app/src/main/res/drawable/large_icon_sample.png new file mode 100644 index 00000000..f8245ccf Binary files /dev/null and b/android/app/src/main/res/drawable/large_icon_sample.png differ diff --git a/src/components/LocalNotificationTest.tsx b/src/components/LocalNotificationTest.tsx index 8651a545..a6b67239 100644 --- a/src/components/LocalNotificationTest.tsx +++ b/src/components/LocalNotificationTest.tsx @@ -68,6 +68,22 @@ export default function LocalNotificationTest({ permissions }: Props) { console.log('schedule result:', result); }; + const scheduleNowWithLargeIcon = async () => { + const notifications: LocalNotificationSchema[] = [ + { + ...createNotification(), + smallIcon: 'ic_stat_icon_sample', + iconColor: '#00ff00', + largeIcon: 'large_icon_sample.png', + }, + ]; + const result = await LocalNotifications.schedule({ notifications }); + + getPendingNotifications(); + + console.log('schedule result:', result); + }; + const scheduleOnce = async () => { const tenSecondsFromNow = new Date(new Date().getTime() + 10000); const notifications: LocalNotificationSchema[] = [ @@ -269,6 +285,90 @@ export default function LocalNotificationTest({ permissions }: Props) { await getPendingNotifications(); }; + const scheduleAndroidBigTextStyle = async () => { + const notifications: LocalNotificationSchema[] = [ + { + ...{ + id: 223, + title: 'Android Big Text Test', + body: 'Testing, 1, 2, 3', + summaryText: 'From Capacitor', + largeBody: + 'Lorem ipsum dolor sit amet, consectetur adipiscing elite. Morbi quis magna lobortis, dignissim tortor eu, congue lectus. Vestibulum in purus sagittis est blandit sodales.\n\nAliquam lacinia mi id erat eleifend, nec elementum ipsum fermentum. Duis cursus eget lorem sed posuere. Aliquam congue sed lacus eget suscipit. Curabitur vulputate sem quis sollicitudin sollicitudin. Sed sed semper ligula. \n\nIn arcu urna, pretium vel cursus vel, interdum quis massa.', + sound: 'beep.aiff', + attachments: [{ id: 'face', url: 'res:///assets/ionitron.png' }], + }, + }, + ]; + + const result = await LocalNotifications.schedule({ notifications }); + console.log('schedule result:', result); + + await getPendingNotifications(); + }; + + const testAndroidInboxStyle = async () => { + const notifications: LocalNotificationSchema[] = [ + { + id: generateId(), + title: '4 New mails from Capacitor', + body: 'You have new messages', + summaryText: '+3 more messages', + largeIcon: 'large_icon_sample.png', + inboxList: [ + 'New direct message from John', + 'New direct message from Jane', + "Don't miss our 50% off sale!", + 'Payment Confirmation', + ], + }, + ]; + + const result = await LocalNotifications.schedule({ notifications }); + console.log('schedule result:', result); + + await getPendingNotifications(); + }; + + const testAndroidGroupStyle = async () => { + const notifications: LocalNotificationSchema[] = [ + { + title: 'Noti1', + body: 'Body1', + id: 1, + schedule: { at: new Date(Date.now() + 1000 * 5) }, + actionTypeId: '', + extra: null, + group: '1', + }, + { + title: 'Noti2', + body: 'Body2', + id: 2, + schedule: { at: new Date(Date.now() + 1000 * 5) }, + actionTypeId: '', + extra: null, + group: '1', + }, + { + title: 'NotiGroup', + body: 'NotiGroup', + id: 3, + schedule: { at: new Date(Date.now() + 1000 * 5) }, + actionTypeId: '', + extra: null, + group: '1', + groupSummary: true, + summaryText: 'Test Summary', + }, + ]; + + const result = await LocalNotifications.schedule({ notifications }); + console.log('schedule result:', result); + + await getPendingNotifications(); + }; + useEffect(() => { if (permissions === 'granted') { getPendingNotifications(); @@ -313,12 +413,23 @@ export default function LocalNotificationTest({ permissions }: Props) {
+

Scheduling Tests

+
+ + Schedule just one + + + Cancel just one + + + Schedule just one (with seconds) + + + Schedule just one (without seconds) + Schedule now - - Schedule now (custom icon on Android) - Schedule in 10s @@ -343,17 +454,21 @@ export default function LocalNotificationTest({ permissions }: Props) { Refresh Pending Notifications - - Schedule just one +

Android Notification Style Tests

+ + Custom Small Icon Test - - Schedule just one (with seconds) + + Custom Large Icon Test - - Schedule just one (without seconds) + + Android Big Text Style - - Cancel just one + + Android Inbox Style + + + Android Group Notification