A Step by Step guide to Push Notifications for Hybrid Mobile App Development

A Step by Step guide to Push Notifications for Hybrid Mobile App Development

Abstract

This article is targeted to the users who are looking for developing Applications with Push Notification. Basically, this article is about brief introduction on Push notification and how we can use push notification with different platform.

Introduction

Push notifications are a type of communication channel built into user’s devices. Messages that are pushed to the user’s desktop, mobiles and other devices in hands-up manner are known as push notification. Push notification is the ability by mobile device or other devices to get message, which are pushed from server side.

Few things must know about push notifications: –

-Push notification is the most important and first communication channel.

-Approx all major apps uses push notification for transactions and re-engagement.

-Today’s push notification technologies are rapidly change form a simple message delivery system to rich and interactive medium.

Push Notification Protocols: –

Push Notification Protocols

To understand, why we use push notification and how it works, there are few important concepts called push and pull protocols.

There are two common ways, in which, notifications are transferred in the world over internet: –

1: – Receiver Pull: -This type of notification occurs when you are requesting for any information over the Internet. Client connects to server and makes the information request and server fulfills the request. Then, client shuts down the connections. WWW is based on the HTTP, which is pull protocol. To load any content, we type the URL on the browser, which initialize the HTTP request to the server and server response back to the browser for that HTTP request.

2: – Sender Push: –Another kind of pull notification is that when you don’t ask for anything’s but you still got notification because you are allowed to published to do that.

Types of push notifications: –

Transactional notification: – To notify the users about event, what systems are using as transactional notification. For example that user notify that their train is delayed.

Broadcast notifications: – While notification broadcast over the server to all users, who are subscribed to this service.

Tag notifications: – These notifications are for those users, who are subscribe for a tag.

Push notification for hybrid mobile applications

Mobile platform which supports push notification: –

Android 2.3.5, 4.x, 5.x +

iOS 6, 7, and 8 +

Windows Phone 8.x +

Windows 8 +

How setup project for Mobile platform. According to the mobile platform, project setup differently.

Android

For Android devices we use Google Cloud Messaging (GCM) service. To register GCM service, we need a valid Google account.

Note:-    Recently, Google announced move GCM to FCM.

Now basically, Android devices use FCM for push notification.

Steps for setup FCM: –

1: – First open firebase console

2: – Create new project and provide name according to your need.

3: – Click on the Settings “cog wheel” icon and select Project settings.

4: – Click the Cloud Messaging tab to generate a Server API Key and a Sender ID and click Save.

IOS

For IOS we are using Apple Push Notification Service (APNS). To use APNS you must be a registered with Apple IOS Developer to obtain certificate for your application. APNS certificates have a non-blank password. Though, for normal cases, iOS devices can also receive push from FCM but in specific cases, say for example when a iOS device suppose to receive a video call and app is either in background or suspended/closed/killed mode, then in such a case to awake iOS device VoIP notifications are required. This can be achieved using Apple APNS service. As a standard, it is always recommended to use Apple APNS service to receive push notification on iOS devices.

1: – In development phase, use the sandbox certificate file (apns-certificate-sandbox.p12)  and place it in the root folder. The environment root folder has the highest priority.

2: – In Production phase, use the sandbox certificate file (apns-certificate-production.p12)  and place it in the root folder. The environment root folder has the highest priority.

Sandbox servers:

gateway.sandbox.push.apple.com:2195

feedback.sandbox.push.apple.com:2196

Production servers:

gateway.push.apple.com:2195

Feedback.push.apple.com:2196

Note: –If hybrid application has iPhone and iPad as target devices, then we need separate certificate to implement Push Notification. In that case, place those certificates in the corresponding environment folders.

Windows

Windows Phone 8 devices use the Microsoft Push Notifications Service (MPNS) to send Push Notification.

There are two notification for Windows: –

Non-authenticated: –Non-authenticated, which does not require any setup from the developer.

Authenticated: –Authenticated requires a Windows Phone Dev Center account for push notification. For authenticated push notification, you must need a certificate which is issued by Microsoft-trusted root certificate authority.

Note:– For production, it is recommended to use authenticated push notification to ensure that notification Is not compromised.

Project Configuration: –

Add the following lines to the application-descriptor.xml file. For setting up push notifications in your application, you can also edit these settings with the Application Descriptor Editor in Design mode.

Android: –

Change into GCM website form you created project: –

1: – Replace GCM_Key with the API Key Value.

2: – Replace senderID with the Project Number value.

<androidsecurityTest=“PushApplication-strong-mobile-securityTest”version=“1.0”>

<pushSenderkey=“GCM_key”senderId=“GCM_ID”/>

 

3: -Add google play service from Android SDK Manager > Extras, add the Google PlayServices option.

4: – Add reference in google-play-service in the“myApp\android\native\AndroidManifest.xml”.

<meta-data

android:name=“com.google.android.gms.version”

android:value=“@integer/google_play_services_version”/>

IOS: –

1: – Apple APNS certificate file place on the root of the application or environment folder.

2:- Replace certificate password.

3: – Replace com.PushNotification with bundleID.

<iphonebundleId=“com.PushNotifications”version=“1.0”>

<pushSenderpassword=“”/>

Window: –

Non-Authenticate Push

<windowsPhone8version=“1.0”>

<uuid>e446f9d1-8d04-4198-be53-9fb44ae47548</uuid>

<pushSender/>

Authenticated Push

<windowsPhone8version=“1.0”>

<uuid>e446f9d1-8d04-4198-be53-9fb44ae47548</uuid>

<pushSender>

<authenticatedPushserviceName=” … “keyAlias=” … “keyAliasPassword=” … “/></pushSender>

Push Notification by FCM

Firebase Cloud Messaging(FCM) offers broad range of messaging and capability. Basically, FCM send two types of message. Notification messages and Data messages. Notification messages are handled by FCM SDK automatically. But Data messages are handled by client app.

Notification Message

If we want to send notification messages programmatically then we must use Admin SDK or FCM protocols. For user visible part of notification messages, we need to set the notification key with the necessary predefined set of key-value options. For example title with state and message with the country name: –

Notification Message

Data Message

To send a data payload to the client app in Data message, we need to set an appropriate key with our custom key-value pair.

Data Message
Use Scenario and How to send

Hope this blog will help you in adding push notification to hybrid apps. But, in case you encounter any challenge, feel free to contact our hybrid app development experts.

About Author:
Author Rohit Choudhary is a full-time Full-Stack developer with 3.5 years of experience in Dot Net, SQL Server, AngularJS and ReactJS. He has good experience in Dot Net web application.

About QSS:
QSS Technosoft has a proven track executing web and mobile applications, where Push Notifications are required to implement. The company has a core competency in developing and delivering Enterprise level applications involving the implementation of transactional and non-transactional push notifications.

Renovate unique Business Processes into Digitally Transformed solutions with QSS Technosoft!!

Do you want to remove manual operations, acting as impediment to your business growth? Realize your ideas into reliable web and mobile software solutions with our professional services. Take first step to launch your project by filling the form.

Let's computerize your business process


or Call Us