Notification only works when app is on screen (android)

  • Using a WeMos D1 R2 via wifi.

  • Using Android 4.4.2

  • Using Blynk 2.27.21

  • Using Blynk server.

  • Not sure how to see what Blynk library version I’m using.

  • When I have the Blynk app on the screen of the phone, notifications come through no problem.

  • When the app is running in the background but is not up on the screen, notifications are ignored.

  • Tried updating Blynk and restarting the phone: no difference.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = "";   

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = ""; 
char pass[] = "";  

unsigned long triptime;

WidgetRTC rtc;

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);

  pinMode(D7, INPUT_PULLUP);
  digitalWrite(D7, HIGH);

  triptime=0;
  setSyncInterval(10 * 60); // Time sync interval in seconds (10 minutes)
}

BLYNK_CONNECTED() 
{
  // Synchronize time on connection
  rtc.begin();
}

void loop()
{
  Blynk.run();
  if(digitalRead(D7)==0 && millis() > triptime) 
  {
    String currentTime = String(hour()) + ":" + minute() + ":" + second();
    String currentDate = String(day()) + "/" + month() + "/" + (year()-2000);
    String message = String(currentTime + " " + currentDate + " D7 tripped.");
    Blynk.notify(message);
    Serial.println(message);
    triptime = millis()+5000;
  }

}

No problems on ESP8266:

⸮[5214] Connecting to WiFi-E83D
[6716] Connected to WiFi
[6716] IP: 192.168.1.103
[6716] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.8 on Arduino

[6722] Connecting to blynk-cloud.com:8442
[7313] Ready (ping: 0ms).
[7886] Time sync: OK
14:36:40 21/12/20 D7 tripped.
14:36:53 21/12/20 D7 tripped.
14:38:31 21/12/20 D7 tripped.
14:38:46 21/12/20 D7 tripped.
14:39:33 21/12/20 D7 tripped.

Your Blynk library version is 0,4.8
This is a very old version, you should be using 0.6.1 or later.

If that doesn’t fix the problem then look at the notification permissions on your phone.

Pete.

Also, you should read this…

Pete.

It used to work no problem (a couple of years ago now.)
WirePusher has no problem with notifications on the same phone.
I’ll try updating the Blynk library.

Updated to Blynk v0.6.1 on the ESP8266.
Problem hasn’t changed on Android.

Uninstalled app on Android. Reinstalled it. Retried it. Changed tone to default. Still only working when app is on screen.

The only notification options on android 4.4.2 is in Settings > Device > Sound > Volumes > Ringtone & notifications, aswell as choosing a default notification sound.