Need help with PushNotification!

Hi there,
I have been struggling in receiving a consistent reliable notification push to my iPhone6 through the amazing Blynk app. I’m using a push button (At Switch Mode) on my dashboard attached to the digital pin 2 on the Arduino board along with the Push Notifications widget. What I want to accomplish is receiving a notification push whenever the push button get depressed, and it should do that only once until the push button get pressed and depressed again (on OFF state). What I’m receiving now is inconsistent push notification as it doesn’t show up every time the button got depressed (toggled to OFF).

I added the command Serial.print( ) before Blynk.notify( ) just to make sure that the code does what it’s meant to do, and it did. I really don’t know whether this is due to some timing issue while sending and receiving the push or it’s something else that I’m not aware of?

Please have a look at my code. Your help and suggestions are highly appreciated. Thank you in advance!` #define BLYNK_PRINT Serial // Now this is needed to print to the notification push
#include <SPI.h>
#include <WiFi.h>
#include <BlynkSimpleWifi.h>

boolean val1 = LOW;
boolean val1Statuse = HIGH;
int X1;

char auth[] = " ";

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, " ", " ");
pinMode(2, INPUT);

while (!Blynk.connect()) {/Wait until connected/}
// Notify immediately on startup
Blynk.notify(“Device started”);
}

void loop()
{
val1 = digitalRead(2);
Blynk.run();
notifyNormalization();
}

void notifyNormalization()
{
val1 = digitalRead(2);
if (val1 != val1Statuse)
{
X1 = 0;
//return;
}
else if (val1 == val1Statuse)
{
switch (val1Statuse)
{
case LOW:
X1 = 1;
val1Statuse = HIGH;
break;
case HIGH:
X1 = 0;
val1Statuse = LOW;
break;
}
}
if (X1 == 1)
{
BLYNK_LOG(“Button is pressed.”);
Serial.println(“The pump has been normalized”);
Blynk.notify(“The pump has been normalized\nتم اعادة المضخة للوضع الطبيعي”);
return;
}
if (X1 == 0)
return;
}
`

Please follow rules of posting the code:

Really sorry for the improper code post in the wrong place :sweat_smile:

Please delete my topic from here as it’s irrelevant to the category. I already reposted it under Need Help With My Project. Thanks