• I have my WordPress installed on DreamHost and I want to add the code needed to send a push notification to the Google servers for my Android app (this just requires curl to POST the info the Google server whenever the events happen right?)

    I looked for plugins that helped to do this but they all seem to require a third party registration which will probably either advertise or require fees to do it so I decided to do it myself. While I know some PHP I’m not very familiar with the wordpress code base so can someone give me a couple pointers as to which files I could insert the code for a push notification happening when a new post is made?

    Thanks!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I would suggest you write a plugin for this. The basic setup is merely a particular PHP comment on the main code page and placing the file somewhere in the wp-content/plugins/ structure.

    You could just place the code in the theme’s functions.php, but you should create a child theme if you go this route. I think this functionality is more for the realm of plugins. Themes relate more to appearance.

    You can leverage the “email administrator” option when posts are published, though other trigger options exist if you don’t like that one. The email administrator function is a “pluggable” function declared in wp-includes/pluggable.php. If you simply copy the function declaration into your plugin file and edit as required, it will be used instead of the core version.

    If you do not need the email part, you can remove it. If you need it or the push notification for some situations and not others and can define those situations in code, then build some sort of conditional code structure into the function.

Viewing 1 replies (of 1 total)
  • The topic ‘Tips on how to add push notification support on post published’ is closed to new replies.