Device-server communication

The SDK has a bi-directional communication model with the server. This enables the SDK to run on a variable frequency model, which balances the fine trade-off between low latency tracking and battery efficiency, and improve robustness. For this purpose, the iOS (Android) SDK uses APNs (FCM) silent remote notifications.

This guide will take you through the setup on React Native.

iOS setup

[info] Prerequisites

This guide assumes you have configured APNs in your application. If you haven't, read the iOS documentation on APNs.

Setting up HyperTrack server-to-device communication with APNs extends the PushNotificationIOS setup in React Native. Once setup, your AppDelegate.m file will have push notifications methods, which we will use in the following steps.

Configure APNs on HyperTrack dashboard

APNs certs Log into the HyperTrack dashboard, and open your account settings. Upload your APNs development and distribution certificates (.pem files). These certificates will only be used to send remote push notifications to your apps.

Enable remote notifications in the app

Background modes In the app capabilities, ensure that remote notifications inside background modes is enabled.

Registering and receiving notifications

The following changes inside AppDelegate.m will register the SDK for push notifications and route HyperTrack notifications to the SDK.

1. Register for notifications

Inside didFinishLaunchingWithOptions, use the SDK method to register for notifications.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [HyperTrack registerForNotifications];

2. Register device token

Inside and didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError methods, add the relevant lines so that HyperTrack can register the device token.

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(nonnull NSData *)deviceToken{
    [HyperTrack didRegisterForRemoteNotificationsWithDeviceTokenWithDeviceToken:deviceToken];

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(nonnull NSError *)error{
    [HyperTrack didFailToRegisterForRemoteNotificationsWithErrorWithError:error];

3. Receiving notifications

Inside the didReceiveRemoteNotification method, add the HyperTrack receiver. This method parses only the notifications that sent from HyperTrack.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    if ([HyperTrack isHyperTrackNotificationWithUserInfo:userInfo]){
        [HyperTrack didReceiveRemoteNotificationWithUserInfo:userInfo];

    // Additional handling for RCTPushNotificationManager

Android setup

[info] Prerequisites

This guide assumes you have configured FCM or GCM in your application. If you haven't, read the Android documentation on FCM.

The Android setup depends on whether you have a fresh install for FCM, or if you are already using notifications.

Fresh setup

In your AndroidManifest.xml file, define HyperTrackFirebaseMessagingService as the listener for FCM.

    <service android:name="com.hypertrack.lib.HyperTrackFirebaseMessagingService">
            <action android:name="" />

Already using notifications

In case you are already using notifications, you need to modify your listener service class implementation:

  1. Pass HyperTrack notifications to the SDK
  2. Handle your own notifications

Test your integration

(Android only) You can test your integration by sending a visible test notification.

curl -H "Authorization: token YOUR_SK_TOKEN" \
     -H "Content-Type: application/json" \
     -X POST \<user-id>/test_notification/

results matching ""

    No results matching ""