This website is no longer maintained. Please, visit documentation.indigitall.com to read our updated documentation.
EN |
ESadvanced guide to configuring the Flutter SDK
In this section you will find a series of more advanced functionalities that require a more complex development. We recommend that a developer be in charge of this configuration.
The indigitall SDK can manage the user's location. This allows you to use the location filters on the send push campaign screen ( Campaigns> Push> New push campaign > Filters> Geographical filters)
Once we have enabled this functionality, the end user will have to give their consent to the location permission and enable the location services of their smartphone, so that the application can obtain the exact location of the user.
Include the requestLocation parameter to your initialization.
...
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "<YOUR_APP_KEY>",
IndigitallParams.PARAM_SENDER_ID: "<YOUR_SENDER_ID>",
IndigitallParams.PARAM_REQUEST_LOCATION: true
}, null, null, null);
...
You can associate your own ID to each device. In this way it will be easier and more intuitive for you to work with our tool. For example:
To make this association between your custom ID (externalId), and the identifier handled by indigitall (deviceId), you have to invoke the setExternalCode method:
IndigitallFlutterPlugin.setExternalCode("YOUR_EXTERNAL_ID", (device) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModelModel
});
Do not you worry about anything. Your IDs are irreversibly encrypted on the phone itself and sent securely to our servers. Not even the indigitall team can know this information.
If it is required to collect the user's WiFi information, in addition to the Indigitall panel configuration, you must add the parameter wifiFilterEnabled when the SDK is initialized:
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "<YOUR_APP_KEY>",
IndigitallParams.PARAM_SENDER_ID: "<YOUR_SENDER_ID>",
IndigitallParams.PARAM_WIFI_FILTER_ENABLED: true
});
The location permission must be accepted by the user
Please note that the WiFi scan time when the app is in the background or closed may be inaccurate.
In order to obtain the Wi-Fi information in android, the following permissions and services declared in the manifest are needed:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
// ANDROID 12 WIFI
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
//WiFi service
<service
android:name="com.indigitall.android.services.WifiStatusService"
android:permission="android.permission.BIND_JOB_SERVICE" >
</service>
<receiver android:name="com.indigitall.android.receivers.WifiWakeLockReceiver">
<intent-filter>
<action android:name="AlarmReceiver.Action.NETWORK_ALARM" />
</intent-filter>
</receiver>
Likewise, you must add in the project options in Xcode, in Signing & Capabilities the option Access WiFi Information :
if you are ENTERPRISE CUSTOMER you have to add this parameter in the configuration so that the SDK points to the correct environment:
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "YOUR_APPKEY",
...
IndigitallParams.PARAM_URL_DEVICE_API: "YOUR_DEVICE_API_DOMAIN",
IndigitallParams.PARAM_URL_INAPP_API: "YOUR_INAPP_API_DOMAIN",
IndigitallParams.PARAM_URL_INBOX_API: "YOUR_INBOX_API_DOMAIN",}
Our SDK offers various callbacks that help you have greater control of the execution flow and implement custom behaviors.
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "YOUR_APPKEY",
IndigitallParams.PARAM_SENDER_ID: "YOUR_SENDER_ID",
IndigitallParams.PARAM_REQUEST_LOCATION: true
}, (device)=> {
//LOG device onIndigitallInitialized
}, (device) => {
//LOG device onNewUserRegistered
}, (error) => {
//LOG IndigitallErrorModel
});
The onIndigitallInitialized callback will be executed when the SDK finishes initializing and the device is ready to receive notifications from indigitall.
It receives as a parameter the Device object with the information associated with the device.
IndigitallFlutterPlugin.init(
{
IndigitallParams.PARAM_APP_KEY: "YOUR_APPKEY",
IndigitallParams.PARAM_SENDER_ID: "YOUR_SENDER_ID",
IndigitallParams.PARAM_REQUEST_LOCATION: true
}, (device)=> {
print("Device: " + device.toString());
}, null, null);
The onNewUserRegistered callback will be executed when the device has been registered for the first time, that is, in the first execution of the app after being installed.
It receives as a parameter the Device object with the information associated with the device.
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "YOUR_APPKEY",
IndigitallParams.PARAM_SENDER_ID: "YOUR_SENDER_ID",
IndigitallParams.PARAM_REQUEST_LOCATION: true
}, null, (device)=> {
print("Device: " + device.toString());
}, null);
The error method will run only if an error occurs during the initialization of the SDK.
It receives the description of the error as a parameter.
IndigitallFlutterPlugin.init({
IndigitallParams.PARAM_APP_KEY: "YOUR_APPKEY",
IndigitallParams.PARAM_SENDER_ID: "YOUR_SENDER_ID",
IndigitallParams.PARAM_REQUEST_LOCATION: true
}, (device)=> {
//LOG device
}, (errorModel) => {
print("Error: "+ errorModel.errorMessage);
});
This section describes the different actions that could be performed on an indigitall device. The device model would have this structure:
You can choose to disable the device to block the receipt of notifications. It is a very useful method to:
To do this, you have the deviceEnable and deviceDisable methods.
You must instantiate a _Device Callback object and pass it as the second parameter. This callback will receive as a parameter the device object that contains all the information associated with the device.
IndigitallFlutterPlugin.deviceEnable((device) => {
// Do something with device in success function
}, (error) => {
// Do something in error function
});
IndigitallFlutterPlugin.deviceDisable((device) => {
// Do something with device in success function
}, (error) => {
// Do something in error function
});
Our SDK allows you to classify users into different customizable groups. This is very useful for:
Remember that you must first define the groups you want to work with in the indigitall console ( Tools> Interest groups ). See our user manual for more info.
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
});
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
});
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
});
If you want to integrate the In-App messages in your application, you can do it with several complementary formats:
Banner. Static content that is always visible, but allows the user to continue using the application. PopUp. Content of a full screen that forces the user to click or discard the information.
Next we tell you how to instantiate one or more In-App messages in banner format.
Remember that you should first have them defined in the indigitall console. See our user manual for more information.
Create a Container, its size must match the one you have defined in the indigitall console ( Tools> In-App Schemas / In-Web ).
Container container = new Container (width: WIDTH, height: HEIGHT);
Once the code has been created to show the InApp, it must be instantiated and called in the showInApp method that we can see below. The code of the InApp, the id of the previous Container, the same container created previously and the appropriate callback must be passed as parameters to obtain the view and the code. This callback will tell us if it has been loaded correctly or not and in relation to this result we will do one action or another.
A code example is here
IndigitallFlutterPlugin.showInApp(IndigitallParams.PARAM_INAPP_CODE: 'YOUR_INAPP_CODE', (inApp, container) => {
//DO SOMETHING
}, (error) => {
// Log error message
});
IndigitallFlutterPlugin.showInAppWithInAppCode('YOUR_INAPP_CODE', container, (container, error) =>
{
//didExpired
}, (container, error) => {
//didShowMore
}, (container, error) => {
//didClickOut
}, (container, error) => {
//dismissForever
}, (inApp, container) => {
//onSuccess
}, (error) => {
//onError
});
If we want to have several InApp, the previous step has to be carried out but with a list of containers and InApp codes
IndigitallFlutterPlugin.showMultipleInApp(IndigitallParams.PARAM_INAPP_CODE: 'YOUR_INAPP_CODE', (inApp, container) => {
//DO SOMETHING
}, (error) => {
// Log error message
});
IndigitallFlutterPlugin.showMultipleInAppWithInAppCode(list_inApp_codes, list_container, (container, error) =>
{
//didExpired
}, (container, error) => {
//didShowMore
}, (container, error) => {
//didClickOut
}, (container, error) => {
//dismissForever
}, (inApp, container) => {
//onSuccess
}, (error) => {
//onError
});
Here we tell you how to instantiate an In-App message in popup format.
Remember that you should first have it defined in the indigitall console. See our user manual for more info.
IndigitallFlutterPlugin.showPopUp(IndigitallParams.PARAM_INAPP_POPUP_CODE: 'YOUR_INAPP_CODE', (inAppCode) => {
//DO SOMETHING
}, (error) => {
// Log error message
});
If you want to customize the icon to close the Popup, you can do it with the following method to which you can pass the name of the image or icon that you must attach in the native versions. In the case of android in the drawable folder and in the case of iOS in assets, if you wanted to use our icon, it would be enough to pass a null. The parameter closeIconDisabled is in case you don't want to show any icon, setting it to true to hide it or false to show it.
InApIndigitallFlutterPluginp.showPopUp(
{
IndigitallParams.PARAM_INAPP_POPUP_CODE: 'YOUR_INAPP_CODE',
IndigitallParams.PARAM_CLOSE_BUTTON: false,
IndigitallParams.PARAM_CLOSE_ICON_DISABLED: 'YOUR_ICON_BUTTON_NAME'
},
(inApp) => {
//DO SOMETHING
},
(error) => {
//DO SOMETHING
}
);
In the event that you want to show the InApp scheme in a different way to how our SDK paints it, we put at your disposal some methods so that you can customize the "painting", without affecting the statistics or the InApp functionalities.
Thanks to the InApp functionalities, it is possible to indicate that the inApp is displayed or pressed a maximum number of times, or if in the case of the popUp, after performing an action, such as pressing the close button, is not shown again.
IndigitallFlutterPlugin.getInApp("inAppId", (inApp) => {
//Show InApp
}, (error) => {
//did expired
}, (error) => {
//did show more
}, (error) => {
//did clickout
}, (error) => {
//dismiss forever
}, (error) => {
//error
});
For the case of what we call Dismiss Forever, once the action is performed, this method must be called:
IndigitallFlutterPlugin.addNewInAppToDismissForever(inApp);
In the event that you want to show an inApp only if you make 'x' clicks or clicks on it, you must add the following:
IndigitallFlutterPlugin.addInAppNewClick(inApp)
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. The device model would have this structure:
We leave you this code that will help to obtain it:
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
});
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) {
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);
}
In this section you will find a series of more advanced functionalities that require a more complex development. We recommend that a developer be in charge of this configuration.
In order to get the notifications from Indigitall's Inbox, the user must identify himself. First you have to initialize the SDK of Indigitall so that it generates our identifier (deviceId) and be able to associate it to the custom ID that you associate to the device, similar to how here .
To perform the registration tasks, these two methods are used:
//Identificación de usuario
IndigitallFlutterPlugin.logIn("YOUR_ID",(device) => {
//DO SOMETHING
}, (error) => {
//LOG IndigitallErrorModel
});
IndigitallFlutterPlugin.logOut(device => {
//DO SOMETHING
}, (error) => {
//LOG IndigitallErrorModel
});
In this section you will see how to generate a validation token for an application that has configured authentication with webhook. To generate this token, you need to add the JSON with the configuration.
To do this, you will have to add a Map with the corresponding configuration in each Inbox call.
Once the device has been successfully registered, you can start making Inbox requests. The following characteristics of the Inbox must be taken into account, which are optionally configurable.
The notifications of the Inbox will have the following states of the class InboxStatus :
Each notification will be assigned with an integer and unique sendingId, to be able to differentiate them and use them for some of the functionalities.
As explained above, to obtain the notifications the following method is used:
IndigitallFlutterPlugin.getInbox({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, (inbox) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
Once the Inbox object has been obtained, we can request the following page, which is made with the following method:
IndigitallFlutterPlugin.getNextPage({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, (inbox) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
Take into account that the Inbox callback, apart from returning the updated Inbox, returns an array called newNotifications, in which the new notifications to be added to the Inbox will be displayed, so that, if necessary, be able to use said array to move between the pages without depending on the Inbox calls.
To get the information for a particular notification, you have to make the following call with the sendingId of each notification:
IndigitallFlutterPlugin.getInfoFromNotificationWithSendingId({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, {sendingId:SENDING_ID}, (inboxNotification) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
To edit the status of one or more notifications at the same time, it is done with the following method in which you must indicate the sendingIds of the notifications to edit and the status to which you want to change:
//Modificar una notificación
IndigitallFlutterPlugin.modifyStatusFromNotificationWithSendingId({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, {
IndigitallParams.PARAM_SENDING_ID:SENDING_ID,
IndigitallParams.PARAM_STATUS:STATUS
}, (inboxNotification) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
//Modificar masivamente
IndigitallFlutterPlugin.massiveEditNotificationsWithSendingIdsList({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, {
IndigitallParams.PARAM_SENDING_ID_LIST:[SENDING_IDS],
IndigitallParams.PARAM_STATUS:STATUS
}, () => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
To find out the number of notifications in the Inbox according to their status, this method is performed:
IndigitallFlutterPlugin.getMessageCount({"YOUR_AUTH_CONFIG_MAP_IF_NEED"}, (counters) => {
//DO SOMETHING
},(error) => {
//LOG IndigitallErrorModel
});
If you have the Firebase plugin installed, you must add this code to ensure that notifications sent from indigitall are received and displayed.
In Firebase callbacks, where you receive a RemoteMessage, if the notification comes from indigitall, the following lines of code will cause it to be painted.
FirebaseMessaging.onMessage.listen((event) {
IndigitallFlutterPlugin.isIndigitallPushNotification(event.data, (isIndigitallPush) => {
if (!isIndigitallPush) {
//DO SOMETHING
}
});