Push notifications allow your application to stay in tune with new events and messages even if the user is not currently using the application. The status bar in Android devices is where a push notifications usually is, you can then click on the notification and the application in which your notification is will open. This is great for marketing campaigns considering these push notifications can be sent to all users irrespective of what they are doing or what applications they are using.
When using a Smartphone device push notifications are a great way to keep you updated. Messages on Facebook or new updates for currently installed applications show up on your status bar as notifications. However if there is an application that isn’t using the push notification tool, fret not, a simple coding change will allow you to use push notifications for any application that you have on your device!
The following method does not require you to have Google Play installed on your device, hence rooted Smartphone users can rejoice! Parse Cloud is a push notification service that remains connected to the Parse library via an internet connection, this library will provide you with push notifications by actively executing a background service! To activate the push notification service using the Parse Cloud for individual apps, you must do the following steps!
1: Register your device for Push service
The application has to register the background service to be able to use push notifications. You can do this by a simple XML addition to your existing AndroidManifest.xml file which is right before the ending </application> tag:
<service android:name=”com.parse.PushService” />
<action android:name=”android.intent.action.BOOT_COMPLETED” />
<action android:name=”android.intent.action.USER_PRESENT” />
2: Grant Permissions
Permissions are required by your applications to actually show you these notifications. Be certain that you grant these permissions for your notifications in the AndroidManifest.xml file. The following is how your androidmanifest.xml file should look like:
<uses-permission android:name=”android.permission.INTERNET” />
<uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />
<uses-permission android:name=”android.permission.RECEIVE_BOOT_COMPLETED” />
<uses-permission android:name=”android.permission.VIBRATE” />
3: Enable the notifications
Lastly now that your application is ready for push notifications, it has to contact the Parse Cloud.
You can do this by allocating a default activity for all push notifications, this is by far the simplest method! You can do this by adding the following two lines on any main activity in your phone!
Once you have done all of these things your phone will be readily using the push notification service via Parse Cloud!