Using push notifications in the Android platform enables you to send interactive notifications to your app users. You can modify the notification parameters, it's visualisation and much more.
- Setup an Android project in the Google Cloud Console
- Configure your app in the PushApps Admin Console
- Integrate the SDK into your app
If you are testing on an emulator - set the target of the emulator to Google APIs
Setup an Android project in the Google Cloud Console
- Open the Google Cloud Console.
Create an API project by clicking CREATE PROJECT.
Once the project that has been created. a page appears that displays your project ID and the project number. For example here,
Project Number: 449866648164.
To enable the GCM service, in the sidebar on the left, select APIs & auth, and In the displayed list of APIs, turn the Google Cloud Messaging for Android toggle to ON.
In the Credentials section, you will see a list of your existing credentials.
- Under the Public API Access click on Create new key, and a 'Create a new key' dialog will appear, there select the Browser key option.
- In the following dialog click on Create.
- Now you have created a Browser key, it should appear in the Credentials sections next to the API key as in the following screenshot. the Browser key is used as the GCM API Key in PushApps.
Configure your app in the PushApps admin console
- Login to the PushApps Admin Console, go to My Apps, choose the relevant app and go to Settings > Manage Platforms and click on Configure by the Android icon. Type your API key.
- After pressing the save button, the Android icon will become green.
Integrate the SDK into your app
- Download the SDK from the PushApps GITHUB repository.
Add the pushapps-vx.x.x.jar file to your project's libs folder. If you use Eclipse, then you should see the pushapps-vx.x.x.jar in the project properties > java build path > Libraries > Android Private Libraries;
If the pushapps.jar does not exists then you need to add it by clicking on Add JARs:
In your main activity, inside the method onCreate(), add the PushApps init line:
For further explanation and more options regarding the sdk please refer to the Android Reference.
Add the following permissions to your AndroidManifest.xml file:
Replace <your package> markup with your package name, e.g: com.pushapps.demo.
Add the following receiver, service and activity, inside your application tag in the AndroidManifest.xml: