katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.75k forks source link

Notification attachment: iOS vs. Android #1869

Open mkn20 opened 4 years ago

mkn20 commented 4 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue. The attachment image for a scheduled notification is shown inconsistently between iOS and Android.

Your Environment

Expected Behavior

For a scheduled notification, notification attachment image consistently shown for both Android and iOS.

Actual Behavior

iOS

The notification attachment image is shown only when a notification is scheduled with foreground set to true as follows:

var notifInfo = {
                id: 111,
                title: "Test Notification",
                text: "Test Notification with attached local image",
                trigger: {
                    at: <A Time in future say 2 days from now>
                },
                 attachments: ['file://<path to a local image>'],
                foreground: true

            };

For a scheduled notification without foregound set the attachment image is not shown while the notification text is being shown all right.

Android

The attachment image is shown just fine without need to set foreground to true. That said, if the notification text has multiple lines, only the first line is shown and the other lines are overwritten by the image. Also, the actions are not shown when that happens.

Has anybody seen the same behavior?

Thanks in advance for any and all pointers and recommendations.

Other questions (as they are not apparent from the documentation):

(1) Can there be multiple attachments (if at all)? (2) Can local video and mp3 files be added as well? (3) For iOS the progress bar doesn't seem to be shown. Is it then supported only for Android? (4) For Android, how to add a different notification icon other than the default bell icon? Should it be drawable resource??

Steps to Reproduce

Code snippet above.

Context

Trying to add notification attachment for the very first time!

Debug logs

mkn20 commented 4 years ago

Following up on this. Thanks in advance.

Epameinondas-Theodoropoulos commented 4 years ago

I have the same problem but with android . I use ionic

Ionic:

   Ionic CLI                     : 5.4.13 (C:\Users\EPAMEINONDAS\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 1.4.0
   @capacitor/core : 1.4.0

Utility:

   cordova-res : not installed
   native-run  : 1.0.0

System:

   NodeJS : v11.5.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

The code is this:

      this.localNotifications.schedule({
        id: 1,
        title: 'My scheduleNotofication',
        text: 'Thats pretty easy scheduleNotofication...',
        data: {mydata: 'My hidden message this is 1'},
        foreground: true, // would be visible even if the app is open
        vibrate: true,
        attachments: ["file:///img/coffee.jpg"], 
        led: '#FF00FF',
        trigger: { in: 8, unit: ELocalNotificationTriggerUnit.SECOND}
    });

i have tried with attachments: also these paths and none have worked: ../assets/img/coffee.jpg D:/Hard Disk/Apps/AthenLairsApp-ALA/android/app/src/main/assets/public/assets/img/coffee.jpg

BUT!!! It works with URL attachments: ["https://cdn.craftbeer.com/wp-content/uploads/coffee2_hero.jpg"]

This show the image