3

i use ionic 4 capacitor to show local notification which i found documentation on there website but documentations are not complete this is their link ionic capacitor local notification documentation

It is working but i don't know how to show image and how to change the icon. i tried a lot of thing.

Is there anyone who tested it and can help me?

this is my code already

    LocalNotifications.schedule({
  notifications: [
    {
      title: "aaaa",
      body: "Body",
      id: 1,
      actionTypeId: 'OPEN_PRODUCT',
      attachments: [
        { id: 'face', url: 'https://khanoo.com/wp-content/uploads/estate_images/house/77-1576179614/230174.jpg' ,options:{}}
      ],
      schedule: {
        every: "minute"
      },

      extra: null
    }
  ]
});
arman codex
  • 527
  • 1
  • 8
  • 18

2 Answers2

0

From the code source, looks like they have some definition for smallIcon (but it's apparently only for Android)...

LocalNotification interface

About the image - not sure what kind of image do you want to show... From the definition, they have the LocalNotificationAttachment that can be used for iOS to show rich notifications. It's something like this

iOS Rich notifications

Monomachus
  • 1,448
  • 2
  • 13
  • 22
  • thanks for reply , do you have code for LocalNotificationAttachment used to show an image on notification ? i do not know how to use that Attachment with url image. for example i used it like this and it is not working ` attachments: [ { id: 'face', url: 'https://khanoo.com/wp-content/uploads/estate_images/house/77-1576179614/230174.jpg' } ], ` – arman codex Jan 04 '20 at 11:14
  • https://github.com/ionic-team/capacitor/blob/473a50e2e087602591891de3f4dac6eafe5d3755/core/src/core-plugin-definitions.ts#L1008 – Monomachus Jan 04 '20 at 12:41
  • Also check this... https://stackoverflow.com/a/39103096/197500 – Monomachus Jan 04 '20 at 12:56
  • Thanks but thats not helpful because i have this code already and it does not show image LocalNotifications.schedule({ notifications: [ { title: "aaaa", body: "Body", id: 1, actionTypeId: 'OPEN_PRODUCT', attachments: [ { id: 'face', url: 'https://khanoo.com/wp-content/uploads/estate_images/house/77-1576179614/230174.jpg' ,options:{}} ], schedule: { every: "minute" }, extra: null } ` ] ` `}); ` – arman codex Jan 04 '20 at 13:02
  • I think you're missing the options – Monomachus Jan 04 '20 at 15:08
  • options is just for ios – arman codex Jan 04 '20 at 18:27
0

The related issue going on this https://github.com/ionic-team/capacitor-plugins/issues/430

http/https urls are not supported by iOS (native API limitation)

on Android and Web the attachments are not shown as images, should be implemented

Muhammed Rahif
  • 434
  • 1
  • 5
  • 17