Push notifications API

[ BETA FEATURE ]

Send highly personalized push notifications to your app users based on usage, behavior, and user experience.

  • Engage with your most active or loyal users and reward them.
  • Enhance your support by sending personalized notifications to users that reported or experienced issues or bugs.
  • Connect with beta testers directly based on their interaction and behavior.
  • Improve retention by targeting slipping away users to re-engage them.
  • Give your users the guidance they need exactly when they need it.

📘

Please note that these notifications are different from in-app notifications, while the in-app notifications are seen within the app ecosystem (only when the app is open), UXCam push notifications are seen outside and when the app is in the background.


Dashboard Implementation

Based on the type of platform you wish to use, you need to configure the following:

Android - Firebase Cloud Message (FCM) server key

You can create the FCM key inside the cloud messaging in the Firebase project settings. For more information on how to get the FCM key, please visit the Firebase documentation.

15621562

Your FCM server key is inside your project settings in Firebase


Once you have created the key, simply copy and paste the server key token inside the “Push notification config”.

iOS - Apple Push Notification (APN) certificate

You can create the APN certificate inside the “Certificates, Identifier and Profiles” inside the apple developer center (developer.apple.com). You can either create Sandbox or a Production certificate based on what type of application you are using. Once you have created the certificate, download it first from the developer center and then upload it inside the “Push notification config”.

🚧

Important

At the moment .cer files are not acceptable based on Apple's requirements so you would need to generate a .p12 file in order to upload the certificate.

To review on how to create a certificate allowed by UXCam, please check the following link


API Implementation:

Once you've configured the key/certificate in your dashboard, you must then use our push notification API, which is a single line of code that will get the device's token and send it to UXCam, allowing you to send notifications to specific users:

UXCam.setPushNotificationToken(_ pushToken: String?)

//Example - Add this to didRegisterForRemoteNotificationsWithDeviceToken
let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
UXCam.setPushNotificationToken(token)
UXCam.setPushNotificationToken(String pushToken);
UXCam.setPushNotificationToken: (pushToken: string) => void

//Example
import messaging from '@react-native-firebase/messaging';

async function sendTokenToUXCam(token) {
    RNUxcam.setPushNotificationToken(token);
  }

useEffect(() => {
  //for Android
  messaging()
    .getToken()
    .then(token => {
      return sendTokenToUXCam(token);
    
  //for iOS
  messaging()
    .getAPNSToken()
    .then(token => {
      return sendTokenToUXCam(token);
    });
UXCam.setPushNotificationToken: (pushToken: string) => void
void setPushNotificationToken(String pushToken)

//Example
void setToken() async {
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  //ForAndroid
  String? token = await FirebaseMessaging.instance.getToken();

  //ForiOS
  String? iosToken = await FirebaseMessaging.instance.getAPNSToken();
 
  if (token != null) {
    FlutterUxcam.setPushNotificationToken(token);
  } else {
    print("Token null");
  }
}

👍

You are all set!

Once you have done the configuration you are ready to send the push notification to your users. You can see how to do it here