Sending Android push notifications in AppPresser
In this tutorial:
AppPresser has released push notifications for their excellent WordPress mobile app platform using the AppPush extension. With this release, AppPresser is further solidifying itself as an authority in native Android and iPhone application development. In this article, we will show you how to enable push notifications in your Android app.
What are push notifications?
Push notifications are messages that can be sent directly to your users directly from your mobile app, so that you can update them on things like specials or any other new information. Push notifications are extremely effective in keeping your users in the loop as to what is going on within your app.
Downloading the AppPush extension
First, log into your AppPresser account. You should already have an account if you have been using AppPresser. If you are not already using AppPresser for your mobile app, you may want to follow our guide on creating an app with AppPresser.
From within your AppPresser account, click on View Details and Downloads for the AppPush extension. If you do not see the AppPush extension there, you will need to purchase it from AppPresser first.
Next, scroll down to the Products section of the page and download the AppPush extension. You will then need to manually install this plugin on your WordPress site.
Getting your Google API key
To enable Android push notifications, you'll need to connect to the Google API. In this section, we'll show you how to do so.
First, you'll need to visit the Google API Developer's Console.
Once inside your developer's console, create a new project by clicking the Create Project button. If you already have a project associated with the app that you are enabling push notifications on, you may click on that project to edit it.
Next, click on APIs. On this page, you will scroll down to Google Cloud Messaging for Android and click the button that says Off to change it to On.
Now that you have Android cloud messaging enabled, you'll just need an API key to access it. To do so, click on Credentials then click Create New Key under Public API access to generate your API key.
Be sure to keep this window open as you will need information from your Google developer's console in later steps.
To send any messages through the AppPresser AppPush extension, you will need to use the Pushwoosh service. In this section, we will show you how to configure Pushwoosh to connect using to your Google API key.
First, you will need a Pushwoosh account. You can obtain a free account on the Pushwoosh website. Once you have created your account, log into it.
From the Pushwoosh Applications tab, click the big green Add new to create a new push notification app.
A box will open up when creating your application asking for some information. First, enter your title and a custom icon that will be displayed on your push notifications.
In the bottom, you will see a few radio buttons to select your SDK. Under Android SDK, select PhoneGap Build (Generic). Once it is selected, click Save.
Next, click on Configure on the left side navigation menu, then click Configure next to the Android section.
You will then be prompted to enter your API key that you got in the previous steps from the Google developers console. Just in case you don't still have that window open, you will log into the Google developers console, click on your app, then click on Credentials. Enter your API key from this page, then click Save.
Configuring the AppPush extension
Of course, the one thing that ties everything together is the AppPush extension. In this section, we'll show you how to configure it to connect to both the Google API, as well as Pushwoosh.
To begin the configuration, be sure that you are logged into your WordPress admin dashboard.
From your WordPress dashboard, click on AppPresser. Once on this page, select the Notifications tab at the top of the page.
On this page, you will enter the following information:
License Key: This is the license key that you received from AppPresser.
Pushwoosh App Code: In this field, you will enter the app code from Pushwoosh. This can be found at the top of the page, on the application page in PushWoosh.
Pushwoosh API Token: This is provided only if you have a premium Pushwoosh account and will let you send push notifications directly from the WordPress admin. If you have a free account, this field is not required.
Google API Project Number: This is the unique project number from your Google API developers console. This is located on the top of the page when viewing your project in the Google API developers console.
Push Post Types: With a Pushwoosh premium account, you will be able to send push notifications directly from your WordPress admin dashboard. These options will allow you to select various post types which will automatically send push notifications when created.
Once you have configured this page, be sure to click Save Settings.
Rebuilding your Android app to enable push notifications
First, you will need to open your PhoneGap build files. If you don't already have these, please review our article on creating apps in AppPresser.
Once you have your PhoneGap build files open, edit the config.xml file. You will need to add the following line to it:
<gap:plugin name="com.phonegap.plugins.pushplugin" />
Once this line is added, save and close the file.
Just as any other typical PhoneGap build, create a zip file out of your PhoneGap files, then visit your app on the PhoneGap website and click the Update code button to begin rebuilding your app. If you are not familiar with building your app in PhoneGap, take a look at the Building your Android or iPhone app with AppPresser article.
For users to receive push notifications, your users will need to have this particular build of your app that has this line within your config.xml file.
Sending push notifications
Sending push notifications from WordPress
If you have a premium Pushwoosh account, you can set WordPress to automatically send push notifications, or manually send them directly from your WordPress admin dashboard. Depending on your settings in place for AppPush, you push notifications will automatically be sent when a new post or page is created. Push notifications may also be sent by hovering over AppPresser, then clicking on Notifications on the left side menu bar.
Sending push notifications from Pushwoosh
If you have a free account, your only option to send push notifications is to do so from the Pushwoosh dashboard. To do so, log into your Pushwoosh dashboard, and click on the application that you created earlier. Here, you will see a text box. Enter your text to send within your push notification, then scroll down to the bottom of the page and click on Woosh!. Your push notification will then be sent to all users of your app.
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!
2014-06-05 3:58 pm
Thanks for your great article! I am about to start developing my app but i was wonfering if there is an affective way to build a notification menu to turn push notification categories on and off by the app users? Would greatly appreciate any suggestions!
2014-06-05 4:52 pm
Hello Jonathan, and thanks for the comment.
I did some searching around and don't see any plugins or scripts that take advantage of the ability to turn on/off notification categories for your app.
But if you are using AppPresser with the AppPush plugin as described in this article, there is the ability to use their notifications custom post type from within WordPress. You could possibly create an extra database field for all of your WordPress users with an option for push notifications to be turned on or off, then in your app allow users to modify this database setting.
Then you could either modify, or create your own plugin copy with an if statement placed right above the code that sends out the notifications to check your database entries and then only push notifications to the users that have it set to on.
The same principle could apply to maintaining other database entries such as if the user only wanted to be notified for certain categories they've selected or something like that.
Please let us know if you had any other questions at all!
2014-06-12 1:07 pm
Thanks for taking the time to check it out! Also, your answer makes complete since. Do you recommend any developers that might be able to whip this task out shortly? Thanks again for you input.
2014-06-12 1:34 pm
Thanks for your response and your question. We unfortunately cannot recommend a developer to you other than the Appresser developer as a suggestion for making the change. You can write to the developers and see if they are able to accommodate your request.
2014-06-14 6:20 am
Good morning, I just set everything correctly, both the config.xml, and make rebuilding my app using phonegap and still not working, you add those missing gap as follows, and still can do the costs push notifications. I need help because I no longer know what else I can do. Indeed very useful manual. I await your response. Best Regards John.
2014-06-16 8:51 am
Could you explain exactly how you are trying to send push notifications? Is it from within WordPress or from the Pushwoosh interface? Be sure that all of your API keys are appropriately set up as well.
2014-06-16 11:07 am
good morning, thank you very much for your reply, I explain in wordpress is configured correctly, and if you send the push but neither Android nor iOS gets the notification, and from Pushwoosh, apaarece all set correct, but do not reach a delivery is made. In Pushwoosh interface, is correct, but fail or Android or iOS notifications in Pushwoosh, subscriber leaves the counter to 0.'s As if the app had no phone.
2014-06-16 11:55 am
It appears that something is not correct in either your app build or within the AppPush extension. As I cannot make any changes or view your exact configuration in this plugin forum, I recommend contacting the AppPresser support for more information. The issue does appear to be somewhere within your communication between the phone/WordPress and the PushWoosh service.