Page 1 of 2

Push notifications from WordPress plugin - Push message blank

Posted: Sun Apr 06, 2014 9:38 am
by Chris6743166

My app receives push notifications from a WordPress plugin (Push Notifications for Posts - http://codecanyon.net/item/push-notif...).

However, the push notification message is blank. Just the name of the app appears.

How do I get the title from the push payload to display in notification?

The plugin developer kindly provided this hint:

[quote:]You can find the post's title in the data field of the notification payload, which in our case is something like:

code"data":{"id":"125", "title":"New Post Title"}/code

Here is an example:
In the class that extends BroadcastReceiver, implement the onReceive(Context context, Intent intent) method.
Here, to get the post's title call:
codeBundle extras = intent.getExtras();/code

codeid = extras.getString("id"); // "125" in our example/code

codetitle = extras.getString("title"); // "New Post Title" in our example/code

To show the alert box then call something like:

codeNotificationCompat.Builder builder = new NotificationCompat.Builder(context)/code

code .setSmallIcon(smallIconId)/code

code.setContentTitle(context.getString(context.getApplicationInfo().labelRes))/code

code .setAutoCancel(true)/code

Code: Select all

   code.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))/code 

code .setContentText(title)/code

code .setContentIntent(contentIntent);/code

code notificationManager.notify(id, builder.build());/code[/quote]


Push notifications from WordPress plugin - Push message blank

Posted: Sun Apr 06, 2014 9:51 am
by Chris6743166

I should add: Sending to Android.


Push notifications from WordPress plugin - Push message blank

Posted: Sun Apr 06, 2014 1:24 pm
by Igor

Hello,

We'll search for a solution and someone will back with updates.


Push notifications from WordPress plugin - Push message blank

Posted: Sun Apr 06, 2014 1:31 pm
by Chris6743166

Thanks Igor.


Push notifications from WordPress plugin - Push message blank

Posted: Sun Apr 06, 2014 9:33 pm
by Alena Prykhodko

Hello,

Please specify where do you put the above code?

Also show us a screenshot of what you see on your phone when the push notification is sent.


Push notifications from WordPress plugin - Push message blank

Posted: Mon Apr 07, 2014 8:48 am
by Chris6743166

Hi Alena,

I'm afraid I don't know where the above code goes. Appery is great because it enables non-coders like myself to build relatively complex apps. I was rather hoping that there was a simple way of retrieving data from the push payload.

Screenshot of push notification as it currently appears attached.

Image


Push notifications from WordPress plugin - Push message blank

Posted: Mon Apr 07, 2014 1:12 pm
by Maryna Brodina

Hello!

Why don't you use Appery.io Push notification service to work with push notifications?
http://docs.appery.io/tutorials/getti... - tutorial for receiving and sending push notifications from server
http://docs.appery.io/documentation/b... - our API for sending push notifications from devices


Push notifications from WordPress plugin - Push message blank

Posted: Mon Apr 07, 2014 2:11 pm
by Chris6743166

Hi Maryna,

I did consider the Appery push notification service option, however, with my limited coding skills, it's far easier to install a WordPress plugin that sends push notifications than to start trying to write (or hiring someone to write) backend WordPress code to send push notifications via Appery server every time the school adds a post to their WP site.

Is there no simple way to process the payload that's coming from the website? As you can see, the push notifications work, it's just that they're missing the post title which should appear as the push message.


Push notifications from WordPress plugin - Push message blank

Posted: Mon Apr 07, 2014 4:21 pm
by Kateryna Grynko

Hi Chris,

Unfortunately third-party plug-ins are outside the scope of our support. You should double check how this plug-in works. Probably you have some incorrect settings there.


Push notifications from WordPress plugin - Push message blank

Posted: Mon Apr 07, 2014 9:09 pm
by Chris6743166

Hi Katya,

I'll ask the plugin developer if they can help. Can you tell me exactly how the payload should be formatted for the push notifications to work? Then I'll pass that information on.

Thanks for your help.