Push notifications

Requirements

  • Use something like react-native-permissions or react-native-push-notification or react-native-firebase to request permission for push notifications.
  • Use react-native-firebase to handle push notifications on Android.

Android

Setup FCM

You'll need to add Firebase Cloud Messaging to your app, and then pass the token to the SDK.

If you need a guide, you can follow the Android docs.

Registering for FCM push notifications

You'll need to register for push notifications with your push notification service, and then pass the token to the SDK.

import KustomerChat from '@kustomer/chat-react-native';
import firebaseMessaging from '@react-native-firebase/messaging';

firebaseMessaging().onTokenRefresh((token) => {
  KustomerChat.setPushToken(token);
});

Handling push notifications

You can pass any properly formatted message from a push notification service to KustomerChat.onRemoteMessage to handle it.

Optionally, you can use KustomerChat.isKustomerNotification to check if the message is from Kustomer, and should be forwarded.

import KustomerChat from '@kustomer/chat-react-native';
import firebaseMessaging from '@react-native-firebase/messaging';

firebaseMessaging().onMessage((message) => {
  if (KustomerChat.isKustomerNotification(message)) {
    KustomerChat.onRemoteMessage(message);
  }
});

iOS

The calls made in JS for Android do not work for iOS, and you'll need to do some native setup.

🚧

This SDK is a work in progress, and the iOS API is subject to change. We will likely end up with a similar API to Android, but for now, you'll need to do the following steps in your native project.

Setup APNS

If you already have iOS push notifications setup, you can, grab your keys and certificates, and move on to the next section.

If you don't have push notifications setup, you'll need to follow the iOS Push Keys and Certificates docs to get your keys and certificates.

Registering for APN push notifications

Follow the iOS Push Notification docs to add the appropriate calls to your AppDelegate.m.