Apps-Script-Gmail-Push-Notifications-v2 icon indicating copy to clipboard operation
Apps-Script-Gmail-Push-Notifications-v2 copied to clipboard

doPost not running

Open veevandyke opened this issue 8 years ago • 4 comments

I am trying to get a push notification to work with this code.

I can see both the topic and the subscription in the PubSub dashboard. Additionally, enroll email works fantastically well.

Unfortunately, after that, nothing happens. doPost never gets hit. Is there something I am missing? Any way to troubleshoot this?

I followed the steps exactly. What else can I look for?

veevandyke avatar May 07 '17 21:05 veevandyke

Just checking again to see if you have any insight for me. I've recreated the project again. I can get pull notifications to work, and credentials are good. but the doPost just isn't getting hit. Where can I go to troubleshoot this? Seems that there is a previous user with the same issue.

Thanks in advance!!

veevandyke avatar Jun 20 '17 21:06 veevandyke

Hi veevandyke, I had the same issue. Replacing return 200; by return HtmlService.createHtmlOutput(""); in the doPlot function made it work for me, as doPlot would then return the correct type.

Seems like if doPlot has a return type error, the whole function is now considered invalid and hence not run. That was probably not the case at the time the code was written.

adrspo avatar Sep 24 '17 13:09 adrspo

I'm having the exact same problem. The topic and subscription with the correct endpoint url show up in my pubsub console, but my endpoint is never invoked. I even injected a message directly in the topic via the console's "PUBLISH MESSAGE" button; same outcome. On the Apps Script side, I can also verify a direct http post to my endpoint url calls the script's doPost() as expected.

adrspo, I tried your suggested change and it made no difference, unfortunately.

veevandyke, did adrspo's change solve the problem in your case?

Any ideas what to try next?

pirandello9 avatar Sep 25 '17 07:09 pirandello9

FOUND THE PROBLEM & SOLUTION:

When you Deploy as web app, the Who has access to the app dropdown must be set to Anyone, even anonymous.

(Seems obvious now... kicking myself for not having thought of this earlier!)

@Spencer-Easton, for the benefit of future users of this script, would you consider adding this detail to your excellent README's step 3?

pirandello9 avatar Sep 26 '17 03:09 pirandello9