Push Notifications

Introduction

Catalyst Push notifications enables you to send remote notifications to the users of your application, even when the app is not actively running on the user device. Catalyst provides you with an easy way to integrate push notifications into your Catalyst web, iOS, and Android applications.

While implementing Push Notifications through the Flutter SDK, you will need to ensure the prerequisites for iOS or Android, depending on the platform you’re building your app in. These prerequisites are described below.

Prerequisites for iOS Apps

Before you send push notifications in your iOS app, you must follow a set of steps to register your app and enroll for Catalyst push notifications. These steps are mentioned in sequence below:

  1. Register your iOS app with Apple
  2. Generate a certificate from Keychain Access
  3. Generate and download the APNs certificate provided by Apple
  4. Convert the downloaded APNs certificate into the .p12 format
  5. Enroll for iOS Push Notification Services in Catalyst
  6. Register a Mobile Device for Push Notifications
Note: The first five steps are covered in detail in the Push Notifications- iOS help section. This SDK help documentation only covers the sixth step regarding registering a device to send push notifications, as well as deregistering a device. You can implement steps 1 -5 by referring to the Push Notifications help document, before using the code given in this section.

Prerequisites for Android Apps

Before you send push notifications, you must follow a set of steps to register your app and enroll for Catalyst push notifications. These steps are mentioned in sequence below:

  1. Generate Firebase’s Android Configuration File
  2. Generate Private Key for Firebase Access
  3. Configure Android Push Notification Services in Catalyst
  4. Register a Mobile Device for Push Notifications
Note: The first three steps are covered in detail in the Push Notifications- Android help section. This SDK help documentation only covers the fourth step regarding registering a device to send push notifications, as well as deregistering a device. You can implement steps 1 -3 by referring to the Push Notifications help document, before using the code given in this section.

Register a Mobile Device for Push Notifications

After you complete the prerequisites mentioned above for the platform that you’re working on, you can implement the following code in your app’s codebase that will register the device for Catalyst Push Notifications.

To register an Flutter mobile device as a test device, you must call the registerNotification() method with the required parameters as shown in the following code snippet:

    
copy
try { var response = await ZCatalystApp.getInstance().registerNotification(deviceToken: deviceToken, notificationAppId: '1624000000074620',isTestDevice: false); print(response?.responseJson); } on ZCatalystException catch (ex) { log("Register Failed: $ex"); }

Parameters:

  • deviceToken: The device token obtained from FCM for you Android app, or the device token obtained after registering the device for remote push notifications with APNS for your iOS app.

  • notificationAppID: For Android, this is the app ID generated by Catalyst for your Android app in Push Notifications, which can be found in the Android section of Push Notifications in your Catalyst console. For iOS, this is obtained from the AppConfigurationDevelopment.plist/ AppConfigurationProduction.plist file generated by Catalyst for your app when you registered your iOS app in Catalyst.

  • testDevice: The value is set to true for test devices, and set to false for production devices.


Note: You can register a maximum of 10 Android or iOS devices as test devices to test Android push notifications.

After your device is registered, you will be able to send push notifications to your app users. The users will need to provide the permission for your app to send push notifications to them on their device, by clicking Allow from the permission prompt.

You can learn about sending test push notifications on your registered devices from the Catalyst console for iOS apps and for Android apps from their respective help documentation. You can also send test notifications from the API.

Refer to the Java, Node.js, and Python SDK documentation to learn about sending push notifications through your codebase.

Last Updated 2024-12-11 17:48:21 +0530 +0530