Push Notifications

Push Notifications

 

Introduction

Push notifications are remote notifications that an application provider can send to the users of their application, even when the application is not actively running on the user device. These notifications are pushed from the server either at scheduled times or whenever you require them to be sent, to the target users that you specify. Push notifications can contain promotional content like alerts about the latest events, offers, or updates related to your business, or actionable elements for the user to re-engage with your application. They are therefore a crucial part of a mobile or a web application, as they provide value to the end users and strengthen your communications with them.

Zoho Catalyst provides you with an easy way to integrate push notifications into your web and iOS applications. For web applications, you can incorporate a code snippet that Catalyst provides into your application's source to enable push notifications in it. For iOS applications, you can easily authenticate your app's APNs configuration with Catalyst, and allow it to forward the push messages that you require. You can also send test notifications to select devices from the Catalyst console for both web and iOS applications, to verify if they are enabled and are working correctly.  

You can use Catalyst APIs to register for push notifications in your iOS and web applications and send notifications to the user devices. For further information, refer to the SDK documentation and the API documentation. You can find information about hosting Catalyst applications on the Device Management and Web Client Hosting help pages.

Note:
  • Catalyst Push Notifications feature is not available to Catalyst users accessing from the EU and IN data centers.
  • Push notification support for Android applications in Catalyst will be available soon. 
 

Purpose

Catalyst servers make the task of incorporating push notifications in your iOS apps a lot easier by acting as an intermediary between you and Apple. Catalyst's push notification API forwards your push messages to Apple on your behalf, and provides you with the response of the request. Additionally, for iOS apps, you can test push notifications both in development and production modes from the Catalyst console. 

For web applications, you can use the code snippet provided in the Catalyst console to define the appearance and action of your push notifications through your own logic and incorporate them into your application's source. Once configured, you can send test push notifications to the email addresses of select users to verify that they are working. 

 

Key Concepts

Before you learn about the architecture of Catalyst push notifications, you should get familiar with some fundamental concepts.

Web Push Notifications

Catalyst push notifications for web applications is a fully managed service which you can use to easily enable and activate push notifications for your web app. 

A Catalyst web app's push notifications are displayed to users when the web app is open in their active browser. However, the browser must support web push and service workers for the notifications to be delivered to the user. You can learn more about these concepts in the Architecture section of the documentation. 

You can write your own action to design the logic for push notifications in the code snippet that Catalyst provides and implement it in your application.  

Depending on the guidelines of the web browsers, you can enable a provision for the users of your web app to opt in to receive push notifications. This can be done by including a prompt requesting permission to allow push notifications. Once the user grants permission, they will be subscribed to receive push notifications from your web app. A unique user subscription ID is created when they provide permission, which allows the web app to send push notifications to them. You can store this ID in your database to identify the subscribers.

As discussed earlier, after you enable and configure push notifications in your web app, you can send test push notifications to specific users from the Catalyst console. You will be able to send plain text notifications to the test clients to check for bugs in the implementation. The users that you send them to must have active sessions of your web app open in their browsers to receive the notifications.

 

iOS Push Notifications

The key concepts of iOS push notifications are explained below:

  1. APNS:

    The iOS push notifications are handled by Apple Push Notifications service, or APNs. Your app is connected to the APNs server when it is installed on a user's device, and this enables the user to receive the notifications that your server forwards to APNs. Catalyst takes the role of the server: it obtains the push messages from you and forwards them to APNs on your behalf, which in turn routes them to the client devices. You can learn more about this in the Architecture section.

    Before you can enroll for Catalyst push notification services, you must obtain an APNs certificate issued by Apple and upload it to Catalyst. The APNs certificate permits the developer to send push notification data to the applications installed on Apple devices. Uploading this certificate to Catalyst establishes a secure connection between Catalyst servers and APNs. 
     
    Note: You must create separate APNs certificates and manage separate APNs connections for each iOS app hosted in different Catalyst projects. You will also need to regenerate your APNs certificate before its validity expires.
  2. Development and Production modes:

    As discussed previously, you can test notifications in both the development and production modes of Catalyst, which are also known as sandboxed and live modes. Apple supports and provides different servers for both these modes.  
     
    Note: The development and production modes of an iOS app are not to be confused with the development and production environments in Catalyst.
    If you select the development mode in the Catalyst console to send test notifications, this will inform Catalyst to forward your notifications to Apple's test servers. Likewise, if you select the production mode to send test notifications, this will inform Catalyst to forward your notifications to Apple's live servers.  

    If your test notifications are delivered to the devices successfully, the APNs connection has been configured properly with your app. When the notifications are sent from your app, you can determine the status of their delivery from the API response you receive.
  3. Registering a user device:

    For iOS apps, the devices that you need to send push notifications to must be registered with APNs. The users must also provide explicit permission for the app to send them push notifications. This can be handled in the app's logic by sending the users a permission prompt, where they can allow or deny permission. Once the permission is provided, you can send test notifications to the device.  

    The steps to be followed to configure and enroll for Catalyst push notification services and test push notifications from the Catalyst console are discussed in detail in the Implementation section.
 

Elements of a Push Notification

The elements of a push notification vary depending on whether it is for a web or an iOS application, mainly because of the differences in standards and restrictions imposed by various web browsers and Apple. Let's elaborate on this for each of the platforms individually.

  1. Web
    Most web browsers do not contain heavy restrictions on HTML customizations or actionable elements that are incorporated in web push notifications. However, unlike native mobile app push notifications, web push notifications do not offer support for a wide variety of media types and interactive elements like GIFs or audio. Additionally, mobile app push notifications can access the mobile phone's camera, accelerometer, and more, which cannot be done by a web app. 

    Different web browsers implement different standards in terms of feature support for push notifications. You must therefore design their appearance and logic accordingly.  

    Broadly, a web push notification can contain elements like:
    • Title and Description
    • App Icon
    • Call-to-action button
    • Website URL
  2. iOS
    Apple supports a variety of rich media and elements that can be included in its push notifications. Since an iOS app is installed on a mobile device, it can also take advantage of the device's camera, GPS, accelerometer, and other hardware.

    Catalyst supports iOS notifications which contain text content. Other elements like audio and video attachments, images, hyperlinks, and call-to-action buttons can also be included as a JSON package. Catalyst also supports notification badge counts in your iOS push notifications. This displays the number of notifications that are waiting to be read in the notification badge.

    You can also perform a variety of actions with iOS push notifications such as:
    • Modifying the notification content before it is displayed to the user
    • Performing a background task
    • Grouping notifications into threads 
    • Providing interactive UI in the notification such as a Like button
    However, you must be aware of the standards defined by Apple and you must adhere to their guidelines before defining actions for iOS push notifications. You can find more information regarding this in their official documentation about generating a remote notification.
 

Architecture

A push message's path, from being sent from an application's provider to being delivered to the intended audience, can be described in a few general steps for both web and iOS applications. In both cases, the key elements involved in passing a push message to the target devices as a notification include:

  1. Service Provider: Your web or iOS application that initiates a push message to be delivered to target users is the service provider. Along with the push message, the request must contain the information that is necessary for a push service to route the message to the right client and to wake up the right service worker.  
  2. Server: The server makes the API call to the push service to request the delivery of a push message. In this case, Catalyst provides the servers that are required to handle all backend activities. API calls to a push service can only be made after Catalyst is configured with it.
  3. Push Service: For web applications, each browser like Chrome and Firefox implements its own push service. The Safari browser and iOS applications implement APNs

    The push service is responsible for validating a push message, waking up the right service worker and routing your message to the targeted devices as notifications. In the case of a web application, the push service also queues your push message until a target device is available to receive it.  
  4. Service Worker: A service worker is a JavaScript file that is idle and listens for a push event to occur. When the push message is routed to a particular device by the push service, the service worker assigned to that device briefly awakens and displays the message as a notification.  

    It follows the constraints as defined in the notification API and displays the notification to the user accordingly. The service worker handles the user's interaction with the push notification. Once the interaction is done, the service worker becomes idle again. Catalyst handles the implementation of the service workers for various web browsers and iOS.

This entire process occupies only a brief amount of time as the push messages that you initiate are delivered to the user devices within seconds, provided all conditions are met.

For the web platform, Catalyst sends a Push API call to the push service to request the delivery of a push message.

For the iOS platform, the process also involves a device token that is globally unique and identifies one app-device combination. Every time a user device launches your app, it sends a request to establish a connection with APNs. Once this is established successfully, the device token is provided to the device by APNs. This establishes the channel between your app and the device. You can learn about this process in detail from the official developer documentation of Apple.

 

Benefits

  1. User Engagement and Retention
    Both web and iOS push notifications help engage users with customized content periodically, or when the user hasn't visited the application in a while. You can also integrate action elements into the notifications so the user can interact with your application directly in the notification panel without having to visit the application. You can send promotional messages about the latest offers, updates, and things happening in your business, and interactive content that grabs the user's attention or makes them visit the application.

    Push notifications in both web and mobile applications allow you to deliver messages instantly to a large audience. This helps you keep in touch with your users and retain them for your business. They create an effective communication channel with your users and guarantee the constant availability of your service to them.
  2. Unlimited Push Notifications 
    There are also no restrictions on the number of messages that you can send to the users of your application from Catalyst's end. For iOS apps, the standards for the limit to the number of push notifications that you can send is set by Apple. 

    For web applications, the standards vary with each push service or browser. However, most browsers do not impose heavy limits on push notifications, and this enables you to use Catalyst's service to fit your business needs.
  3. High Throughput Delivery
    Catalyst ensures a high delivery rate of push notifications that keeps pace with the throughput of the notifications that you send from the application.  

    Catalyst servers are fast and are capable of instantly delivering your push messages to the intended push service workers for web push notifications, and APNs servers for iOS push notifications. You can experience lag-free and instantaneous delivery of push messages from your application.
  4. Auto Scaling
    Catalyst servers are equipped with an auto-scaling feature that allocates required resources to your application whenever the load increases. The resources are scaled up or down instantly based on the throughput of the push messages received for your application.  

    Auto-scaling supports even a large number of push messages that you send and ensures consistency in your app's performance. This also eliminates failures in delivering the notifications due to heavy loads.  
  5. Delivery through a Single API Request
    You can use Catalyst APIs to enable push notifications for a particular user's device for the web or iOS app, when the user grants permission. You can also send push notifications to an unrestricted number of user devices using a single API request. With this easy publishing functionality, you can save time and effort while sending periodical scheduled push notifications, or notifications that are sent as required.
  6. Easy Implementation
    Catalyst helps you in automating the task of sending push notifications and makes managing your application a lot easier. For example, for manual push notifications, you can incorporate a pop-up box or something similar in the admin access of your application, for your app's admins to type in and send push notifications to target users manually.  

    For scheduled or automatic push notifications, you can use Catalyst APIs to retrieve the list of target devices from the Catalyst Data Store or elsewhere, and send push messages to all of them with a single API call.
 

Use Cases

Catalyst push notification service can be used in the following scenarios, among others:

  • A taxi-booking application sends iOS push notifications to its new customers if they have not opened the app for a certain amount of time after they sign up for an account. It includes engaging content that gives brief information about the types of cabs available in the form of a banner image, and a call-to-action button 'Learn more!' which redirects them to the app.  

    The organization obtains a list of the new users from the Catalyst Data Store through APIs. This user list is passed on to use as the recipients of the push notifications in the application's code. The code also defines the time gap between the sign up and initiating the push message, the time of the day it must be sent, and more.  
  • A food delivery app sends iOS push notifications and web push notifications to their customers on a regular basis. The push notifications are customized based on various factors like the user's location, the number of times they have used the app, their food preference history, and more. 

    For example, based on a user's location and previous food preferences, a push notification is sent to suggest an offer available at a nearby restaurant, along with a call-to-action button that redirects the user to the maps feature to see where the restaurant is. These notifications are tested from the Catalyst console before being sent to the customers.  
 

Implementation

The implementation section will guide you through the steps to set up push notifications and send test push notifications. 

 
 

Web

The code snippet provided by Catalyst for the web platform also handles the registration process of the user devices to receive push notifications from the application. You do not need to register the user devices exclusively. You can enable push notifications and start testing them from the console.

Enable Push Notifications

To enable push notifications for a web application in Catalyst:

  1. Navigate to Amplify and then Push Notifications.
  2. Copy the given code snippet from the Web section using the copy icon. Paste this code in your web application's source wherever necessary.
Note: For the push notifications to be enabled properly, you must ensure that you have included the Catalyst Web SDK initialization script in your web application.

The code snippet invokes the enableNotification() function and allows you to define your own action under messageHandler. As mentioned previously in the Key Concepts section, you can handle the appearance and functioning of the push notifications in your app's code using your own logic.

Testing Push Notifications

Once you incorporate and enable push notifications in your application's code, you can test that they are working from the console. Catalyst allows you to send a test text notification to one email address at a time from the console. If the test account receives the notification successfully, you can be assured that the setup is working correctly.

To send a test push notification for a web application hosted in Catalyst:

  1. Navigate to Amplify and then Push Notifications.
  2. Enter the email ID of the user account that you want to send test push notifications to and the message in the Web section.
  3. Click Send.

The push notification will be sent to the specified user immediately. 

For the user to be able to receive the notification, the following criteria must be met:

  1. The user must have the web app open in their browser. If the user is active on a different browser tab, they will still be able to receive the push notification.
  2. The browser that the web app is open in must support web push and service workers
  3. If you have included a permission prompt in your application's logic to allow push notifications, then the end users must have provided permission for it. 
 

iOS

The steps to be followed for configuring and enrolling for Catalyst Push Notification services for an iOS app are listed below in a logical sequence:

  1. Register your iOS app with Apple:

    You must sign in to your Apple developer account and register your iOS app with Apple before you can procure an APNs certificate for it. While creating the app ID, ensure that you provide the same bundle ID for your app that you provided in Catalyst when you downloaded the iOS SDK. You can refer to Apple's  Developer Account Help page for more information.
     
    Note: Ensure you have created an App ID without a wildcard. Wildcard IDs cannot use the push notification service. 
  2. Generate a certificate from Keychain Access:

    You must generate a Certificate Signing Request (CSR) from your Mac OS terminal and upload it in the Apple Push Notifications Portal.

    To generate the CSR from Keychain Access:
    1. Launch the Keychain Access application in your Mac OS terminal. 
    2. Select Keychain AccessCertificate AssistantRequest a Certificate From a Certificate Authority.
    3. Enter your email address and check the option to save the certificate on your disk. 
    4. Save the certificate.
  3. Generate and download the APNs certificate provided by Apple:

    After generating the CSR, open your Apple developer account to generate the APNs certificate as follows:
    1. Select your app from the App IDs list and click Edit.
    2. In the Development SSL Certificates section, click Create Certificate and click Continue.
    3. Upload the CSR file that you created in the previous step and click Continue.
    4. Download the APNs certificate that is generated and click Done.
  4. Convert the downloaded APNs certificate into the .p12 format:

    The APNs certificate that you download from Apple will be in .cer format, which you must convert to .p12 before uploading it to Catalyst. 

    You can convert a .cer certificate to .p12 format in the following way:
    1. Double-click on the downloaded certificate on your Mac to install it in Keychain Access.
    2. Open Keychain Access and locate the installed certificate in the Certificates section.
    3. Click on the arrow next to the certificate to show the key and select it.
    4. Select File and then Export Items...
    5. Provide a name for the export file. Save the file in the .p12 format.
    6. Provide a password to protect the certificate. You will need this password while enrolling for Catalyst Push Notification services. Click OK.
    7. Enter your Mac password to enable the export. Click Allow.
    Your APNs certificate is now saved in the .p12 format.
  5. You can now upload the APNs certificate to the Catalyst console and enroll for Catalyst Push Notification services. This will establish a connection between Catalyst and APNs for your iOS app. The procedure is explained below.
  6. After you have enrolled, you must register your test mobile devices. This allows the devices to receive push notifications that you send them. The procedure to register iOS mobile devices as test devices is explained below.

Once you have followed all these steps to configure and set up the push notification service, you can then start sending test notifications to the registered devices.

 

Enrolling for iOS Push Notification Services in Catalyst

You can provide the necessary information to enroll for Catalyst Push Notification services and upload the APNs certificate in Settings. You will also need to provide your app's bundle ID and the password that you created for the APNs certificate. You must upload the APNs certificate separately for the development and production modes. 

Note: To send test notifications from the development or the production mode, there must be an APNs certificate uploaded in Catalyst for that mode. 

To enrol for push notifications for your iOS app in Catalyst:

  1. Navigate to Settings and then Push Notifications under Project Settings.
  2. Select the project to configure iOS push notifications for, from the Change Project dropdown list in the Push Notifications settings. The current project is selected by default.
  3. Enter your iOS app's bundle ID in the configuration section.
    Note: Ensure that you enter the same bundle ID while downloading the iOS SDK, registering your iOS app with Apple, and configuring push notifications in Catalyst. 
  4. You must upload the APNs certificate for each of the modes to be able to test push notifications in that mode.

    Upload the APNs certificate in the .p12 format under development, production, or both, based on your requirements. Enter the password that you created while saving your APNs certificate in .p12 format.
  5. Click Enroll

This will enroll you for the Catalyst iOS push notification service. Once your APNs certificate is uploaded and its credentials have been provided, Catalyst establishes a connection with APNs for your iOS app. You can then use the console to send test notifications to mobile devices after registering them. You can switch projects using the dropdown list on the top and configure push notifications for it.

Registering a Test Mobile Device

You can register a maximum of 10 iOS devices as test devices to test iOS push notifications.  

To register an iOS mobile device as a test device, you must call the ZohoCatalyst.enablePush(String regid, boolean istestdevice) code from the device. 

You must use the registration ID obtained from Apple for receiving push notifications to replace “regid” in the code. You can learn more about this from the iOS SDK documentation

After a mobile device has been registered, the user must also provide permission for your app to send push notifications to them by clicking Allow from the permission prompt. Once this is done, you will be able to send test notifications to the device.

Sending iOS Test Push Notifications to the Registered Mobile Devices

Catalyst allows you to send a test notification as text to all the user devices that have been registered. You can send notifications for both the production and development modes from the console. Apple allocates different servers for each of these modes. While the app is still in the development state, you can send test notifications in the development mode, and move on the production mode once the development is complete.

To send a test push notification for an iOS app hosted in Catalyst:

  1. Navigate to Amplify and then Push Notifications.
  2. Click the iOS tab in the Push Notifications page.
  3. Click on either the Production or Development tabs in the Push Notifications page.
  4. Enter the message for the push notification and click Send.

The message will be sent as a push notification to the user devices that have been registered for your iOS app.

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocatalyst.com