EddyVerbruggen / nativescript-local-notifications

:mailbox: NativeScript plugin to easily schedule local notifications
MIT License
162 stars 57 forks source link

Everything is fine... But Notification doesn't show up. #40

Closed Taremeh closed 6 years ago

Taremeh commented 7 years ago

I installed the plugin for Nativescript 2.4 (Android). So far I used the demo code and everything seemed fine.

I also got the console.log, that the Notification is scheduled. But there is no Notification showing up... And I don't get any errors...

Someone experiencing the same problem? Is there a solution?

  LocalNotifications.schedule([{
    id: 1,
    title: 'The title',
    body: 'Recurs every minute until cancelled',
  }]).then(
      function() {
        console.log("Notification scheduled");
      },
      function(error) {
        console.log("scheduling error: " + error);
      }
  )
Taremeh commented 7 years ago

Same issue for {NS} 2.5. Upgraded everything today and still no clue what's wrong... If I check currently scheduled Notifications, they're listed even there! But in the end, no Notifications pops up...

JS: Notification scheduled
JS: ID's: 0,1
EddyVerbruggen commented 7 years ago

You'll need to pass in the at property, otherwise the notification is triggered immediately and you won't see it as your app is already in the foreground.

Taremeh commented 7 years ago

@EddyVerbruggen Unfortunately that doesn't help:

LocalNotifications.schedule([{
        id: 61,
        title: 'The title',
        body: 'Recurs every minute until cancelled',
        at: new Date(new Date().getTime() + (5 * 1000)) // 5 seconds from now
    }]).then(
        function() {
            console.log("Notification scheduled");
        },
        function(error) {
            console.log("scheduling error: " + error);
        }
    );

Console says:

JS: Notification scheduled
JS: ID's: 0,1,61,59,60

(Notification 0, 1 => instant; 61 => 5 seconds from now; 59, 60 => 10 seconds from now). They're stuck somehow...

EddyVerbruggen commented 7 years ago

Can you please mail me your app so I can check it out?

Taremeh commented 7 years ago

It's actually on Github. I created a branch.

https://github.com/Taremeh/apphovenAlpha/tree/notification-plugin-issue

Here the notification code: https://github.com/Taremeh/apphovenAlpha/blob/notification-plugin-issue/apphovenAlpha/app/pages/home/home.component.ts#L38-L58

EddyVerbruggen commented 7 years ago

You branch doesn't compile because of this line:

screen shot 2017-02-11 at 20 41 58

Once that works, will it be easy and obvious to reproduce the issue?

And just checking: you did close your app within 5 seconds after scheduling that notification, right?

Taremeh commented 7 years ago

Unfortunately not... I deleted the composer (and even search component). Still the same issue.

Btw. Would it be possible to create a notification while the app is running?

EddyVerbruggen commented 7 years ago

I'm not sure what your answers refer to. Did you fix the branch so I can try and reproduce the issue?

And did you close the app within 5 sec after scheduling the notification?

oncul commented 7 years ago

Same problem on android i am using 2.4.3

oncul commented 7 years ago

Ok i tested on real device and its working. On genymotion emulator notifications not working.

francorobles commented 7 years ago

Hi @EddyVerbruggen, I am planning to use this. Is this already working? It doesn't seem to work on mine too.

seusmanakram commented 6 years ago

@Taremeh please help same issue notifications get scheduled but don't show up!

Taremeh commented 6 years ago

It's still a big pain. I could not get it to work properly... Unfortunately there is (still) no documentation about how to use & build native notifications with Nativescript... But maybe @EddyVerbruggen could provide some help? 😄 I'd still love to know how to create a notification, which persists until an app event drops it. (Not a scheduled one, but one that pops up while using the app).

Danziger commented 6 years ago

@Taremeh @usmanakram1996 @francorobles I managed to get it working on my app by setting forceShowWhenInForeground: true, but I had to do some changes in local-notifications.ios.ts:182.

I have opened a PR with those changes, but it might take a while until we get them, as it looks like @EddyVerbruggen is now working on a major refactor on the Android part.

Tested it on real devices, not sure it would work in an iOS emulator.

EddyVerbruggen commented 6 years ago

Yeah that forceShowWhenInForeground is part of the refactor and not on npm yet.

EddyVerbruggen commented 6 years ago

Going to publish plugin version 3.0.0 in a minute.