Integrating Push Notification in PhoneGap Android Application
If you are building your app using Phonegap platform, integrating App42 Push Notification in it is a very simple task and can be done in a few easy steps. We have created a sample PhoneGap Android application using App42 JavaScript API for the same and can be get started in few easy steps as shown below:
Here are the few easy steps to run this sample app. 1. Register with App42 platform. 2. Create an app once you are on Quick start page after registration. 3. If you are already a registered user then login to AppHQ console and create an app from App Manager Tab. 4. To use Push Notification Service in your Android application, create a new project in Google API Console. 5. Click on services option in Google console and enable Google Cloud Messaging for Android service. 6. Click on API Access tab and create a new server key for your application with blank server information. 7. Go to AppHQ console and click on Push Notification and select Android Settings in Settings option. 8. Select your app and copy server key that was generated by using Google API console in step 6 and submit it. 9. Download the project from here and import it in the eclipse. 10. Open index.html file in assets/app42 folder of sample app and make the following changes: A. Replace api-Key and secret-Key that you have received in step 2 or 3 at line number 51. B. Replace your user-id by which you want to register your application for PushNotification at line number 52.
11. Open App42PhonegapPush.java file in sample app and make the following changes. A.
Replace
project-no
with
your
Project
Number
at
line
number
28.
12. Build your android application and install it on your android device. Test and verify PushNotification from AppHQ console A. After registering for PushNotification go to AppHQ console and click on PushNotification and select application after selecting User tab. B. Select desired user from registered User-list and click on Send Message Button. C. Send appropriate message to the user by clicking Send Button.
Design Details: Following are the high level design details which includes different App42 API usages for integration purpose in the sample.