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.

IndigitallFlutterPlugin.sendCustomEvent({
  IndigitallParams.PARAM_EVENT: "YOUR_CUSTOM_EVENT", 
  IndigitallParams.PARAM_CUSTOM_DATA:{}, () => {
    // 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.
IndigitallFlutterPlugin.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 String[]
IndigitallFlutterPlugin.topicsSubscribe(topics, (topics) => {
  // Do something with topics in success function
}, (error) => {
  // Do something in error function
});

// topics is typeof String[]
IndigitallFlutterPlugin.topicsUnsubscribe(topics, (topics) => {
  // 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.indigitall.indigitall_flutter_plugin.services.IndigitallFirebaseMessagingService"
         android:exported="false">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
</service>

On iOS yo have to add the followings methods:

@available(iOS 10.0, *)
    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
      // get info silent push
        IndigitallFlutterPlugin.sendNotification(notification.request.content.userInfo)
        completionHandler(Indigitall.willPresentNotification());
    }

    @available(iOS 10.0, *)
    override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        IndigitallFlutterPlugin.handleTapNotification(response)
        Indigitall.handle(with: response)
    }
    
    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
      //get token
        IndigitallFlutterPlugin.sendToken(deviceToken)
        Indigitall.setDeviceToken(deviceToken)
    }
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler{
    [CDVIndigitall.cdvIndigitallPlugin sendNotification:notification.request.content.userInfo];
    ...
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [CDVIndigitall.cdvIndigitallPlugin sendToken:deviceToken];
    ...
}

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 method, which will return a map in json format.

IndigitallFlutterPlugin.onMessageReceived((notification) => {
  //get the notification
}),

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

IndigitallFlutterPlugin.isIndigitallPushNotification(notification, (isIndigitallPush) => {
  //get boolean
})

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

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

In case of 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. The device model would have this structure.

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

Android

For Android, by calling the following method and once the notification is clicked, the push object will be received with the corresponding information:

IndigitallFlutterPlugin.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, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
IndigitallFlutterPlugin.handleTapNotification(response)
  Indigitall.handle(with: response ,withCompletionHandler: { (push, action) in
        print("Push object:", push)
        print("Push action app:", action.app)
    })
}

//@DEPRECATED
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    print("Push notification received: \(userInfo)")
    let data = userInfo["data"]
    let push = INPush(data as! NSMutableDictionary)
    print("Push object : \(push)")
#import <Indigitall/Indigitall.h>

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

//@DEPRECATED
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
    NSLog(@"Push notification received: %@", userInfo);
    NSMutableDictionary *data = userInfo[@"data"];
    INPush *push = [[INPush alloc]init:data];
    NSLog(@"Push object: %@",push);
}

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)")
  }
}