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:
- Navigate to Notify and then Push Notifications, in the Catalyst Cloud Scale cosole.
- Copy the given code snippet from the Web section using the copy icon. Paste this code in your web application’s source wherever necessary.
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:
- Navigate to Notify and then Push Notifications, in the Catalyst Cloud Scale cosole.
- Enter the email ID of the user account that you want to send test push notifications to and the message in the Web section.
- 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:
- 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.
- The browser that the web app is open in must support web push and service workers
- 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:
- 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.
- 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:
i. Launch the Keychain Access application in your Mac OS terminal.
ii. Select Keychain Access < Certificate Assistant > Request a Certificate From a Certificate Authority.
iii. Enter your email address and check the option to save the certificate on your disk.
iv. Save the certificate.
- 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:
i. Select your app from the App IDs list and click Edit.
ii. In the Development SSL Certificates section, click Create Certificate and click Continue.
iii. Upload the CSR file that you created in the previous step and click Continue.
iv. Download the APNs certificate that is generated and click Done.
- 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:
i. Double-click on the downloaded certificate on your Mac to install it in Keychain Access.
ii. Open Keychain Access and locate the installed certificate in the Certificates section.
iii. Click on the arrow next to the certificate to show the key and select it.
iv. Select File and then Export Items…
v. Provide a name for the export file. Save the file in the .p12 format.
vi. Provide a password to protect the certificate. You will need this password while enrolling for Catalyst Push Notification services. Click OK.
vii. Enter your Mac password to enable the export. Click Allow.
Your APNs certificate is now saved in the .p12 format.
-
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.
-
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.
To enrol for push notifications for your iOS app in Catalyst:
- Navigate to Settings and then Push Notifications under Project Settings.
- 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.
- 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. - 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. - 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:
- Navigate to Amplify and then Push Notifications.
- Click the iOS tab in the Push Notifications page.
- Click on either the Production or Development tabs in the Push Notifications page.
- 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.
Last Updated 2023-09-15 19:40:38 +0530 +0530
Yes
No
Send your feedback to us