Local Notification issue


#1

Local notfication is getting a major problem to me !

schedule(){
 let now = new Date().getTime();
    let time1=new Date(now+60000);
this.localNotifications.schedule({
            id:1,
            title: "deneme",
            text: "Biraz kelime çalışalım mı ?",
            at: time1,
            sound: "file://assets/sound/speed_camera.mp3",
           
        }




}

Local notification is used with backgroundmode plugin .

I got interesting unexpexted behavior.When the phone is awake it works fine .However when the phone is in sleep(locked and blackscreen) ,LocalNotification is sometimes triggered sometimes not but even if it works ,it has a delay from 5 mins to 15 mins.

* Version of Plugin:@ionic-native/local-notifications": "^3.5.0",
*Platform Android
*OS :Windows 10
*Lenova A6020a41 Android version 5.1
*Cordova version 6.5
*Installed platforms: android 6.1.2

If needs more information please let me know Thank you in advance


#2

I’m having this issue too.

@techsnake did you ever find a solution?

I’m using local notifications and background mode.
It works fine when the device is awake.

If I lock the screen but keep the screen on (still on the lock screen) it works. But once I let the screen go black it doesn’t send the notification and then randomly it will come through at some point.

These features are something so critical to a lot of applications these days yet they’re so hit and miss.


#3

Nope sorry i couldnt find any solution .


#4

@techsnake

I have found a solution that worked for me it gave me both things I was looking for, a heads up notification and the notifications working when the device is locked and screen is dimmed.

It had one minor drawback in that the device doesnt light up when the notification is received but the sound plays and it works when scheduled. (EDIT: On second look this may be just my phone as it happens with all notifications from any application)

My solution was to uninstall the ionic-native plugin for local notifications and use this fork https://github.com/DavidBriglio/cordova-plugin-local-notifications

Add to your project:


cordova plugin add https://github.com/DavidBriglio/cordova-plugin-local-notifications

Then in the page you’re using local notifications:

Put this up top:
declare var cordova;

then:

this.plt.ready().then(()=> {
         (<any>cordova).plugins.notification.local.schedule({
         id: 1,
         title: "Title",
         text: "Text",
         headsup: true
         at: Date.now()
       });
   });

Local notifications, correct behavior?
#5

i ll try it for the next project thanks for contribution


#6

this is really works for you?

on different types of phones?

I doubt because the github have long time without any updates. :frowning:


#7

This did really work for me. Heads up notifications were working on iOS. Just not on android. The problem was that the priority attribute was missing from the ionic wrapper. This was since fixed and added in the ionic wrapper. You need to have priority set to 1 to get a heads up notification on android. I haven’t tested the ionic wrapper but I can confirm that the fork I used from the local notifications repository worked for me. I did not use the ionic wrapper.


#8

I have other question, also happen to you that notifications when were opened, were double?

I don’t identify the pattern, but sometimes opened double and sometimes not :S.

The other thing, the notification doesn’t show in exactly time, is displayed in a range within one minute, that it happen to you too?

I modified the plugin code with something that i saw in pulls requests from katzer github, and works, but sounds two times, and the third not, after two times more, and again not, is very strange.

If I dont modify this in plugin, always sounds, but not in exact time :frowning: .

And i see that works in background mode in android with david briglio’s fork :slight_smile: Thanks!!.

However, I should try different phones. :stuck_out_tongue: