Closed bphick closed 5 years ago
Hi,
can you post your arduino script!
to understand
// Using an ESP-WROOM-32 version of a NODEMCU
/#include
// Initialize Wifi connection to the router char ssid[] = "My_SSID"; // your network SSID (name) char password[] = "My_Password"; // your network key
// Pushsafer private or alias key
/WiFiClientSecure client;/ WiFiClient client; Pushsafer pushsafer(PushsaferKey, client);
void setup() { Serial.begin(115200);
// Set WiFi to station mode and disconnect from an AP if it was Previously // connected WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100);
// Attempt to connect to Wifi network: Serial.print("Connecting Wifi: "); Serial.println(ssid); WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); }
Serial.println(""); Serial.println("WiFi connected"); Serial.print("IP address: "); Serial.println(WiFi.localIP());
pushsafer.debug = true;
// Take a look at the Pushsafer.com API at // https://www.pushsafer.com/en/pushapi
struct PushSaferInput input; input.message = "This is a test message From ESP32"; input.title = "Hello Bryan!"; input.sound = "8"; input.vibration = "2"; input.icon = "149"; input.iconcolor = "#66ffff"; input.priority = "2"; input.device = "a"; input.url = "https://www.pushsafer.com"; input.urlTitle = "Open Pushsafer.com"; input.picture = ""; input.picture2 = ""; input.picture3 = ""; input.time2live = ""; input.retry = ""; input.expire = ""; input.answer = "";
Serial.println(pushsafer.sendEvent(input));
Serial.println("Sent"); }
void loop() { }
Thank you for looking into this! It is very much appreciated. "My" code is above. Other than library changes to get it to compile for the ESP-WROOM-32 version of a NodeMCU, it is virtually unchanged from the example code.
Also, the phone is on Android V9.
can you take a look in the arduino debug log and post the response! Please take a look at the faq for Android 8+ devices https://www.pushsafer.com/en/faq#answer27
Kevin
Correct. I have all of the notifications On. One difference, is that once a custom sound is selected, the App provided sound disappears and is no longer available. I have setup a custom sound and was not able to return the App to the original state. Custom sounds do trigger from the Web. I had tried to reinstall the App, but it kept the state from the previous load.
Debug log as of just now, this does not always show up:
C:\Users\Owner\Documents\Arduino\libraries\pushsafer-arduino-library-master\src\Pushsafer.cpp: In member function 'String Pushsafer::sendEvent(PushSaferInput)':
C:\Users\Owner\Documents\Arduino\libraries\pushsafer-arduino-library-master\src\Pushsafer.cpp:133:10: warning: unused variable 'c' [-Wunused-variable]
char c;
^
Sketch uses 658950 bytes (50%) of program storage space. Maximum is 1310720 bytes. Global variables use 38352 bytes (11%) of dynamic memory, leaving 289328 bytes for local variables. Maximum is 327680 bytes.
I just ran it again, and no such message appears... But I have seen the message before.
The message appears upon any new full debug / compile; anytime the debug option changes.
I cleared all data from the phone as well as the cache regarding Pushsafer. That did allow me to return to the default sound as "App provided sound." However, it still will not push Notifications unless the App is up, and still no sound or Icon ever shows outside of the App.
Hello,
to check if the arduino script or your phone not work correctly. Please copy this script into a .html file and save it to your pc and open it in a browser of your choice.
<script>
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("POST", "https://www.pushsafer.com/api", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.onreadystatechange = ProcessRequest;
xhttp.send("t="+escape('TEST')+
"&m="+escape('THIS IS A TEST')+
"&d=[YourDeviceID]"+
"&k=[YourPrivateKey]"+
"&i=82"+
"&s=8"+
"&v=3"+
"&u="+escape('https://www.google.de?q=test')+
"&ut="+escape('Google Search')
);
function ProcessRequest() {
document.write('ReadyState: '+xhttp.readyState+'<br>');
document.write('Status: '+xhttp.status+'<br>');
document.write('ResponseText: '+xhttp.responseText+'<br>');
}
</script>
change the values in []
Running the above script yields the following in the browser window:
change the values in []
Oops, sorry. I probably need to fill in some values before it will work. Sorry. Let me try again.
Sorry, am I missing something? I filled out the &d, and &k parameters, still receive the same result: "
change the values in []"
I ran it both in Chrome and IE (running on Windows7 machine). IE says: "Internet Explorer restricted this webpage from running scripts or ActiveX Controls." I clicked the popup "Allow Blocked Content" but no change.
OK, I manipulated the script a bit. Now I have a message! "ReadyState: 2"
It flashes: "ReadyState: 1 Status: 0 ResponseText: change the values in []"
Then clears the screen and says: "ReadyState: 2"
That was from my PC... I emailed the script to my phone and I get this response from the phone browser: "ReadyState: 2 Status: 250 ResponseText: ReadyState: 3 Status: 250 ResponseText: {"status":0,"error":"invalid key"} ReadyState: 4 Status: 250 ResponseText: {"status":0,"error":"invalid key"}"
invalid key = check it
ReadyState: 2 Status: 200 ResponseText: ReadyState: 3 Status: 200 ResponseText: {"status":1,"success":"message transmitted","available":984,"message_ids":"4076363:16216"} ReadyState: 4 Status: 200 ResponseText: {"status":1,"success":"message transmitted","available":984,"message_ids":"4076363:16216"}
OK the push transmitted correctly to the google server!
What you can set under "Set as Default"?
Mostly battery managers prevent receiving push notifications correctly. Open System settings, then Advanced Settings, then Battery Manager, and finally Protected apps. Enable the toggle next to Pushsafer to allow it to keep running even after the screen is turned off.
For Samsung Devices Exclude the Pushsafer app from any of the battery optimization features on your device. You'll find these in Settings, then Battery. You'll need to disable battery optimization for the Pushsafer app, as well as checking to make sure the Restrict background data setting is disabled.
Here is a really good blog post to fix broken push notifications https://www.forbes.com/sites/bensin/2017/05/05/samsungs-battery-paranoia-broke-the-galaxy-s8s-push-notifications-just-like-chinese-smartphones/#4926bb1e7a91
Please leave a feedback
Sorry, while it was off, that does not appear to be the problem. Still no change.
OK, after further testing, what the Forbes article actually does makes it so that the full App doesn't stop running in the background... until you click "Close All' or swipe the App off of the active list. Still, no Icon or light notification works even then. Sound comes through. If one hits the "Close All Apps" or swipes the App off (closing it in Android 9), then nothing at all works again. Still, under no circumstances does anything appear as an Icon, no status light blinks, no notification in the upper bar.
please try the following
Send the notifications out of your pushsafer dashboard (website) https://www.pushsafer.com/en/dashboard#anchorsend
i credited you some extra api calls for testing!
i think the app should run in background, here a post https://updato.com/how-to/manage-android-apps-running-background
I looked at" set under "Set as Default". While most Apps on the phone are listed, Pushsafer is not.
Case - Results: 1) send a push notification while the app is in front - Message visible, sound and nearly immediate response in window. 2) send a push notification while the app is in background - Message visible, sound and nearly immediate response in window. 3) send a push notification while the app fully closed - Nothing.
Wondering why you are not listed here in the default choices.
Now it seems that we are going backward. Now it does not notify with an icon, etc. even from the Web interface... it originally did.
set as default you can set up with which app an file type should open. not interesting for pushsafer The app should run in background! This is very important!
Try to set the priority to 2 and also choose a sound in the web interface!
can you send a screenshot of the notification channels set up
I am unable to find that path in Android 9. Let me understand. The above path should be on my phone or somewhere else?
the path is from android 9 > i think on Samsung devices its little different Please take a look at your first screenshot, normally you should see notification channels Sound 0-60 for the pushsafer app
Are these the spot?
notification categories is right there must be categories called from Sound 1 - Sound 60 do you see different categories for pushsafer app?
If not i think channel not correctly installed while insalling the app! Please delete all app data frpm pushsafer, deinstall pushsafer, reboot your device and install again! After that take a look at the notification prefs, if you see theses 60 channels / categories
btw you need to check sound & pop-up
I have completed that two times before today and once prior to this today. Out celebrating my birthday today. Will do a major App scrubbing and complete reload in the morning and let you know how it turns out. I am very, very appreciative of the work you are doing to help me set this up! Thank you!
happy birthday - what a coincidence - today i have my 40. birthday
Happy Birthday!! I am now 59... getting old. ;-)
Yesterday night, after all had left my home, I purged my device from the web account. Then purged the cache and data from my phone and uninstalled the App. Then reinstalled a squeaky-clean version of the App. Now, from the Web interface Pictures to follow this message:
Case - Results:
1) Send a push notification while the app is in front - Message visible, sound and nearly immediate response in window. No Icon. 2) Send a push notification while the app is in background, sound selected - No sound. No Icon. 2a) Send a push notification while the app is in background, no sound selected - NO sound and nearly immediate response in window Icon in bar. 3) Send a push notification while the app fully closed - Nothing. Until booting the App. 4) Send from ESP32 with App Closed - Nothing. Until booting the App. 4a) Remove sound variable from Arduino Code - Send from ESP32 - App in background - receive Icon. 4b) Turn OFF the App in the background - Send form ESP32 - App NOT running in background - RECEIVED ICON! ;-) No colors, no sound. but 2 vibes and the bell icon appeared.... surprise result!
Arduino code: struct PushSaferInput input; input.message = "This is a test message From ESP32"; input.title = "Hello Bryan!"; input.sound = ""; input.vibration = "2"; input.icon = "73"; //149 is a spigot icon, 73 is a flooding house icon input.iconcolor = "#66ffff"; input.priority = "2"; input.device = "a"; input.url = "https://www.pushsafer.com"; input.urlTitle = "Open Pushsafer.com"; input.picture = ""; input.picture2 = ""; input.picture3 = ""; input.time2live = ""; input.retry = ""; input.expire = ""; input.answer = "";
Hi, I tried the script through an ESP32 programmed from the Arduino IDE (1.8.9) sending to a Samsung Galaxy S8 Android phone.
The text portions do come through to the phone only if the App is open. Additionally no notifications come in, and if any parameters such as the r or p are changed to a value, the script yields no result at the phone at all. I also tried from the on-line dashboard to send a message, and the phone responds PERFECTLY. Notifications work, sound works, etc. So I am left to conclude that the problem lies with the script. I'm a very newbie, so I really don't know where to begin to troubleshoot. I'm hoping a fully workable version with notifications and sound could be made with a bit of tweaking by a knowledgeable person.