Advanced Settings

Retargeting

Your app can send information to indigitall's servers to identify the actions and events that happen in it. This allows you to automate retargeting actions.

To register these events you have to call the sendCustomEvent method, passing a descriptive ID as a parameter (you can invent the one you like best) and set data you need on JSON object.

Indigitall.sendCustomEvent({event: "YOUR_CUSTOM_EVENT", customData:{}, () => {
    // Do something in success function
},(error) => {
    // Do something in error function
});

Topics

Our SDK allows you to classify users into different customizable groups. This is very useful for:

  • Implement a preferences screen so that the user can choose the topics for which they want to receive notifications.
  • Label according to the navigation or actions that the user performs.
  • Segment communications according to whether the user has identified or is anonymous.
  • Segment based on language, culture, customer category, or based on any other criteria you need.

Remember that you must first define the groups you want to work with in the indigitall console (Tools> Topics ).

  • List groups
    Use the topicsList method to get the list of groups that are configured in your indigitall project. The callback of this method receives as a parameter an array of Topics, which contains the information of all the available groups, as well as a flag that indicates whether the user is included in any of them.
Indigitall.topicsList((topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

Manage subscription
To manage the device subscription to one or more groups, there are two methods: topicsSubscribe and topicsUnsubscribe.

Optionally, both receive a TopicsCallback object as the third parameter, which will return the list of all Topic in the project.

// topics is typeof Topic[]
Indigitall.topicsSubscribe(topics, (topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});
// topics is typeof Topic[]
Indigitall.topicsUnsubscribe(topics, (topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

// topics is typeof String[]
Indigitall.topicsSubscribeWithStringParams(topics, (topicsSubscribeWithStringParamsList) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});
// topics is typeof String[]
Indigitall.topicsUnsubscribeWithStringParams(topics, (topicsSubscribeWithStringParamsList) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

Collection of push data

If you want to get the info of silent push, on Android you must change the indigitall services on android manifest:

<!-- change this code-->
<service android:name="com.indigitall.android.push.services.FirebaseMessagingService"
         android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

<!--to this code -->
<service android:name="com.indigitallreactnativeplugin.services.IndigitallFirebaseMessagingService"
         android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

In case of that a silent push is sent, or you want to collect the push data before it is tapped, you must add the following event listener, which will return an object in json format.

import {
  NativeEventEmitter,
} from 'react-native';

const eventEmitter = new NativeEventEmitter(IndigitallReactNative);

eventEmitter.addListener('onMessageReceived', (notification) => {
	//do something
});

To differentiate if the push is from indigitall or not, you can use this method, passing data obtained in the previous method:

Indigitall.isIndigitallPushNotification(
  notification,
  (success) => {
   //do something
  },
  (error) => {
    //log error
  }
);

If you want to collect the token, add the following method:

Indigitall.getToken((token) => {
  //do something
}, (error) => {
  //log error
});

In the event that you want to obtain the push object of type json to perform checks and / or when the user clicks on the notification and is with the action of open app.

We leave you this code that will help to obtain it:

Indigitall.getPush(push => {
    //DO SOMETHING
    },(error) => {
      // Do something in error function
    });
iOS

In the case of iOS, you have to import the Indigitall library and add the following methods in the application's AppDelegate:

import Indigitall

@available(iOS 10.0, *)
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
  // get info silent push
  DispatchQueue.main.async {
      NSNotificationCenter.defaultCenter().postNotificationName("onMessagedReceived",  object:nil, userInfo:notification.request.content.userInfo);
  };
  completionHandler(Indigitall.willPresentNotification());
}

@available(iOS 10.0, *)
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
  IndigitallReactNativePlugin.handleTapNotification(response)
  Indigitall.handle(with: response)
}

override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  //get token
  IndigitallReactNativePlugin.sendToken(deviceToken)
  Indigitall.setDeviceToken(deviceToken)
}
#import <Indigitall/Indigitall.h>
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
     dispatch_async(dispatch_get_main_queue(), ^{
      [[NSNotificationCenter defaultCenter] postNotificationName:@"onMessagedReceived" object:nil userInfo:notification.request.content.userInfo];
  });
    ...
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [IndigitallReactNativePlugin  sendToken:deviceToken];
    ...
}
- (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler{
  	[IndigitallReactNativePlugin handleTapNotification:response];
    [Indigitall handleWithResponse:response withCompletionHandler:^(INPush * _Nonnull push, INPushAction * _Nonnull action) {
        NSLog(@"Push object: %@", push);
        NSLog(@"Push object app: %@", action.app);
    }];
}

Push Secure Received Event - iOS platform

On Android is implemented into native sdk, but on iOS you have to add code.

🚧

Only on API use of Push Secure Sending

If you want to receive an event that indicate if the push comes with sendEventAck flag and the encrypted pushes are active, add the following on AppDelegate on didReceived method:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
  Indigitall.didReceivePush(withNotification: userInfo) { push in
    print("Push notification with push secure: \(push.pushId)")
  }
}