This website is no longer maintained. Please, visit documentation.indigitall.com to read our updated documentation.
EN |
ESadvanced guide to configure the iOS 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.
Add the following keys to the application's Info.plist file.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Can we always use your location?</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Can we always use your location?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Can we use your location when using the apps?</string>
The NSLocationAlwaysUsageDescription, NSLocationWhenInUseUsageDescription, and NSLocationAlwaysAndWhenInUseUsageDescription keys can be customized by editing the content of the
There are two ways to manage location permissions:
Here we explain how to configure location permissions in automatic mode.
The locationPermissionMode parameter must be added when the SDK is initialized. This is done using the following code excerpt:
let config = INConfig(appKey: "<YOUR-APP-KEY>")
config.locationPermissionMode = .automatic
Indigitall.initialize(with: config, onIndigitallInitialized: nil, onErrorInitialized: nil);
INConfig *config;
config.appKey = @"<YOUR-APP-KEY>";
config.locationPermissionMode = PermissionModeAutomatic;
[Indigitall initializeWithConfig:config onIndigitallInitialized:nil onErrorInitialized:nil];
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:
//Remember to put your external code here
Indigitall.setExternalCode("", onSuccess: { (device) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
//Remember to put your external code here
[IndigitallObjc setExternalCodeWithCode:@"YOUR_EXTERNAL_ID"
success:^(INDevice *device) {
//DO SOMETHING
} failed:^(INError* error){
//LOG ERROR
}];
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 configuration of the Indigitall panel, you must add the Access WiFi Information option in the project options, in Signing & Capabilities:
And add the parameter wifiFilterEnabled when the SDK is initialized:
let config = INConfig(appKey: "<YOUR-APP-KEY>")
config.wifiFilterEnabled = true
Indigitall.initialize(with: config, onIndigitallInitialized: nil, onErrorInitialized: nil);
INConfig *config;
config.appKey = @"<YOUR-APP-KEY>";
config.wifiFilterEnabled = true
[Indigitall initializeWithConfig:config onIndigitallInitialized:nil onErrorInitialized:nil];
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.
If you are ENTERPRISE CLIENT you have to add this parameter in the configuration so that the SDK points to the correct environment:
let config = INConfig(appKey: "<YOUR-APP-KEY>")
config.domain = "YOUR_DEVICE_API_DOMAIN"
config.domainInApp = "YOUR_INAPP_API_DOMAIN"
config.domainInbox = "YOUR_INBOX_API_DOMAIN"
Indigitall.initialize(with: config, onIndigitallInitialized: nil, onErrorInitialized: nil);
INConfig *config = [[INConfig alloc]initWithAppKey:@"<YOUR-APP-KEY>"];
config.domain = "YOUR_DEVICE_API_DOMAIN"
config.domainInApp = "YOUR_INAPP_API_DOMAIN"
config.domainInbox = "YOUR_INBOX_API_DOMAIN"
[Indigitall initializeWithConfig:config onIndigitallInitialized:nil onErrorInitialized:nil];
Our SDK offers various callbacks that help you have greater control of the execution flow and implement custom behaviors.
To subscribe to these callbacks you have to:
Indigitall.initialize(withAppKey: "<YOUR_APP_KEY>", onIndigitallInitialized: { (permissions, device) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
[Indigitall initializeWithAppKey:@"<YOUR_APP_KEY>" onIndigitallInitialized:^(NSArray<INPermissions *> * _Nonnull permissions, INDevice * _Nonnull device) {
//DO SOMETHING
} onErrorInitialized:^(INError * _Nonnull onError) {
//LOG ERROR
}];
The onIndigitallInitialized method will run when the SDK finishes initializing and the device is ready to receive notifications from indigitall.
Receive as parameter:
Here we show you an element that prints logs about the status of permissions and device information.
Indigitall.initialize(appKey: "<YOUR_APP_KEY>",
onIndigitallInitialized: { (permission, device) in
print("onIndigitallInitialized Push \(permissions[0].permissionType) permission: \(permissions[0].permissionStatus)")
print("onIndigitallInitialized Location \(permissions[0].permissionType) permission: \(permissions[1].permissionStatus)")
print("onIndigitallInitialized DEVICE: \(device.deviceID )")
}, onErrorInitialized: { (error) in
//LOG ERROR
}
[Indigitall initializeWithAppKey:@"<YOUR_APP_KEY>" onIndigitallInitialized:^(NSArray<INPermissions *> * _Nonnull permissions, INDevice * _Nonnull device) {
NSLog(@"onIndigitallInitialized Device: %@",device.deviceID);
NSLog(@"onIndigitallInitialized Permission push: %u : %u", permissions[0].permissionType, permissions[0].permissionStatus );
NSLog(@"onIndigitallInitialized Permission location: %u: %u",permissions[1].permissionType, permissions[1].permissionType)
} onErrorInitialized:^(INError * _Nonnull onError) {
//LOG ERROR
}];
The onNewUserRegistered method will be executed when the device has been assigned the push token to receive notifications, that is, in the first execution of the app after being installed and after having accepted permissions. This is defined in the AppDelegate as callback of the call to the setDeviceToken described above
It receives as a parameter the Device object with the information associated with the device.
Indigitall.setDeviceToken(deviceToken) { (token) in
print("NewUserRegistered: \(token)")
}
[Indigitall setDeviceToken:deviceToken onNewUserRegistered:^(INDevice * _Nonnull device) {
NSLog(@"Device: %@",device);
}];
The onErrorInitialized method will be executed only if an error occurs during the initialization of the SDK.
It receives the error description as a parameter.
Indigitall.initialize(appKey: "<YOUR_APP_KEY>",
onIndigitallInitialized: { (permission, device) in
//DO SOMETHING
}, onErrorInitialized: { (error) in
print("ERROR: \(error.message)")
}
[Indigitall initializeWithAppKey:@"<YOUR_APP_KEY>" onIndigitallInitialized:^(NSArray<INPermissions *> * _Nonnull permissions, INDevice * _Nonnull device) {
//DO SOMETHING
} onErrorInitialized:^(INError * _Nonnull onError) {
NSLog(@"Error Initialized: %@",onError);
}];
You can use the getDevice method to get the information that the SDK has recorded regarding the device.
The callback of this method will receive as a parameter the device object that contains all the information associated with the device.
Indigitall.getDeviceWith(onSuccess: { (device) in
print("Device: \(device.deviceID ?? "")\nStatus: \(device.enabled ?? false)")
}, onError: { (error) in
print("Error: \(error.message)")
})
[Indigitall getDeviceWithOnSuccess:^(INDevice * _Nonnull device) {
NSLog(@"DEVICE: %@ \nStatus: %d", device.deviceID, device.enabled);
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
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 enableDevice and disableDevice methods.
The callback of these methods will receive as a parameter the device object that contains all the information associated with the device.
Indigitall.enableDeviceWith(onSuccess: { (device) in
print("Device: \(device.deviceID ?? "")\nStatus: \(device.enabled ?? false)")
}, onError: { (error) in
print("Error: \(error.message)")
})
Indigitall.disableDeviceWith(onSuccess: { (device) in
print("Device: \(device.deviceID ?? "")\nStatus: \(device.enabled ?? false)")
}) { (error) in
print("Error: \(error.message)")
}
[Indigitall enableDeviceWithOnSuccess:^(INDevice * _Nonnull device) {
NSLog(@"Device: %@ \nStatus: %d",device.deviceID,device.enabled);
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
[Indigitall disableDeviceWithOnSuccess:^(INDevice * _Nonnull device) {
NSLog(@"Device: %@ \nStatus: %d",device.deviceID,device.enabled);
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
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 </ a>). 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 INTopics, 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.topicsListWith(onSuccess: { (topics) in
print("TOPICS: \(topics)")
}) { (error) in
print("Error: \(error.message)")
}
[Indigitall topicsListWithOnSuccess:^(NSArray<INTopic *> * _Nonnull topics) {
NSLog(@"TOPICS: %@",topics);
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
To manage the device subscription to one or more groups, there are two methods: subscribe and unsubscribe .
Optionally, both receive a TopicsCallback object as the third parameter, which will return the list of all Topic in the project.
Indigitall.topicsSubscribe(withTopic: [Topic.code, Topic.code], onSuccess: { (topics) in
self?.topics = topics
}) { (error) in
print(error.message)
}
Indigitall.topicsUnSubscribe(withTopic: [Topic.code, Topic.code], onSuccess: { (topics) in
self?.topics = topics
}) { (error) in
print(error.message)
}
[Indigitall topicsSubscribeWithTopic:@[Topic[0], Topic[1]] onSuccess:^(NSArray<INTopic *> * _Nonnull topics) {
topics = topics.self;
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
[Indigitall topicsUnSubscribeWithTopic:@[Topic[0], Topic[1]] onSuccess:^(NSArray<INTopic *> * _Nonnull topics) {
topics = topics.self;
} onError:^(INError * _Nonnull error) {
NSLog(@"ERROR: %@", error.message);
}];
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, call the sendCustomEvent method, passing a descriptive ID as a parameter (you can invent the one you like the most) and set data you need.
Indigitall.sendCustomEvent("YOUR_CUSTOM_EVENT", customData: []) {
// Do something in success function
} onError: { (error) in
//ERRROR DO SOMETHING
}
[Indigitall sendCustomEvent:@"" customData:@[] onSuccess:^{
// Do something in success function
} onError:^(INError * _Nonnull error) {
//ERROR DO SOMETHING
}];
If you want to integrate the In-App messages in your application, you can do it with several complementary formats:
Below 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 info.
Create a UIView view on your storyboard. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ). Remember to translate the units from PX to iOS points.
@IBOutlet weak var myBanner: UIView!
@property (weak, nonatomic) IBOutlet UIView *myBanner;
Instantiate In-App messages using the showInApp method.
Indigitall.show(inApp: "myBanner_CODE", view: myBanner) { actions in
print("Did touch with actions")
} onShowTimeFinished: { inApp, showTime) in
//DO SOMETHING
} didExpired: { inApp, error in
//DO SOMETHING
} didShowMoreThanOnce: { inApp, error in
//DO SOMETHING
} didClickOut: { inApp, error in
//DO SOMETHING
} success: { inApp in
//DO SOMETHING
} failed: { error in
// LOG ERROR
}
[Indigitall showInApp:myBanner_CODE view:myBanner didTouchWithAction:(INInAppAction *action^{
// DO SOMETHING
} onShowTimeFinished:^(INInApp * _Nonnull inApp, int showTime) {
// DO SOMETHING
} didExpired:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} didShowMoreThanOnce:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} didClickOut:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} success:^(INInApp * _Nonnull) {
// DO SOMETHING
} failed:^(INError * _Nonnull error) {
// LOG ERROR
}];
Create multiple views of UIView on your storyboard. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ). Remember to translate the units from PX to iOS points.
@IBOutlet weak var viewBanner: UIView!
@IBOutlet weak var viewBannerTwo: UIView!
@IBOutlet weak var viewBannerThree: UIView!
...
@property (weak, nonatomic) IBOutlet UIView *viewBanner;
@property (weak, nonatomic) IBOutlet UIView *viewBannerTwo;
@property (weak, nonatomic) IBOutlet UIView *viewBannerThree;
...
Create an array of the views and codes of the inApp that you define in the console and instantiate the In-App messages using the showMultipleInApp method.
var viewList = [UIView]()
viewList.append(viewBanner)
viewList.append(viewBannerTwo)
viewList.append(viewBannerThree)
var webViewCodes = [String]()
webViewCodes.append("myInApp_code_banner")
webViewCodes.append("myInApp_code_banner_two")
webViewCodes.append("myInApp_code_banner_three")
Indigitall.showMultiple(inApp: webViewCodes, listView: viewList) { inApp, view, action in
print("INAPP didTouch: \(inApp.inAppId) y vista: \(view)")
} onShowTimeFinished: { (inApp, view, showTime) in
print("INAPP onShowTimeFinished: \(inApp.inAppId) y vista: \(view) en \(showTime)ms")
view.isHidden = true
} didExpired: { inApp, error in
print("INAPP didExpired: \(inApp.inAppId) error: \(error.message)")
} didShowMoreThanOnce: { inApp, error in
print("INAPP didShowMoreThanOnce: \(inApp.inAppId) error: \(error.message)")
} didClickOut: { inApp, error in
print("INAPP didClickOut: \(inApp.inAppId) error: \(error.message)")
} success: { inApp, view in
print("INAPP success: \(inApp.inAppId) y vista: \(view)")
} failed: { error in
print("ERROR: \(error.message)")
}
NSMutableArray <UIView *> *viewList;
[viewList addObject:yourCustomView];
[viewList addObject:yourCustomViewTwo];
[viewList addObject:yourCustomViewThree];
NSMutableArray <NSString *> *webViewCodes;
[webViewCodes addObject:@"myInApp_code_banner"];
[webViewCodes addObject:@"myInApp_code_banner_two"];
[webViewCodes addObject:@"myInApp_code_banner_three"];
[Indigitall showMultipleInApp:webViewCodes listView:viewList didTouch:^(INInApp * _Nonnull inApp, UIView * _Nonnull webView, INInAppAction *action) {
// DO SOMETHING
} onShowTimeFinished:^(INInApp * _Nonnull inApp, UIView * _Nonnull webView, int showtime) {
// DO SOMETHING
} didExpired:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} didShowMoreThanOnce:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} didClickOut:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
// DO SOMETHING
} success:^(INInApp * _Nonnull inapp, UIView * _Nonnull view) {
// DO SOMETHING
} failed:^(INError * _Nonnull error) {
// LOG ERROR
}];
}];
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.
Create a WebView view in your layouts. The size must match what you have defined in the indigitall console ( Tools> In-App / In-Web Schemas ). Remember to translate the units from PX to iOS points.
Indigitall.showPopup("myInApp_code_popup", didAppear: {
// DO SOMETHING
} didCancel: {
print("Did cancel")
} didTouchWithAction: {
print("Did touch")
} didDismissed: {
print("Did dissmised")
} onShowTimeFinished: { inApp, showTime in
print("Did onShowtimeFinished \(inApp.inAppId) on \(showTime)ms")
} didExpired: { inApp, error in
print("Did didExpired")
} didShowMoreThanOnce: { inApp, error in
print("Did didShowMoreThanOnce")
} didClickOut: { inApp, error in
print("Did didClickOut")
} didDismissForever: { inApp, error in
print("Did didDismissForever")
} failed: {error in
print("Did failed \(error.description) with message: \(error.message)")
}
[Indigitall showPopup:@"myInApp_code_popup-Inapp" didAppear:^{
// DO SOMETHING
} didCancel:^{
// DO SOMETHING
} didTouchWithAction:^(INInAppAction *action){
// DO SOMETHING
} didDismissed:^{
// DO SOMETHING
} onShowTimeFinished:^(INInApp *inApp, int showTime){
// DO SOMETHING
} didExpired:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didShowMoreThanOnce:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didClickOut:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didDismissForever:^(INInApp *inApp, INError *error){
// DO SOMETHING
} failed:^(INError * _Nonnull error) {
// LOG ERROR
}];
If you want to customize the icon to close the Popup, you can do it with the following method to which you can pass a custom UIButton , if you want to use our icon, just pass a null. The closeIconDisabled parameter is in case you don't want to show any icon, setting it to true to hide it or false to show it.
let closeButton = UIButton()
.
.//set UIButton params
.
Indigitall.showPopup("myInApp_code_popup-InApp", closeIcon: closeButton, closeIconDisabled: false) {
print("Did appear")
} didCancel: {
print("Did cancel")
} didTouchWithAction: { action in
print("Did didTouchWithAction")
} didDismissed: {
print("Did dissmised")
} onShowTimeFinished: { inApp, showTime in
print("Did onShowtimeFinished \(inApp.inAppId) on \(showTime)ms")
} didExpired: { inApp, error in
print("Did didExpired")
} didShowMoreThanOnce: { inApp, error in
print("Did didShowMoreThanOnce")
} didClickOut: { inApp, error in
print("Did didClickOut")
} didDismissForever: { inApp, error in
print("Did didDismissForever")
} failed: {error in
print("Did failed \(error.description) with message: \(error.message)")
}
[Indigitall showPopup:@"myInApp_code_popup-InApp", closeIcon: closeButton, closeIconDisabled: false, didAppear:^{
// DO SOMETHING
} didCancel:^{
// DO SOMETHING
} didTouchWithAction:^(INInAppAction *action){
// DO SOMETHING
} didDismissed:^{
// DO SOMETHING
} onShowTimeFinished:^(INInApp *inApp, int showTime){
// DO SOMETHING
} didExpired:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didShowMoreThanOnce:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didClickOut:^(INInApp *inApp, INError *error){
// DO SOMETHING
} didDismissForever:^(INInApp *inApp, INError *error){
// DO SOMETHING
} failed:^(INError * _Nonnull error) {
// LOG ERROR
}];
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.
InAppHandler.init().getInApp(inAppId) { content, inApp in
//DO SOMETHING
} errorLoad: { error in
//Show error
}
[[[InAppHandler alloc]init] getInApp:inAppId success:^(NSString *content, INInApp *inApp) {
//DO SOMETHING
} errorLoad:^(INError *error) {
//Show error
}];
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. To do this we could do the following within the inAppGet method that we have seen previously:
InAppHandler.init().getInApp(inAppId) { content, inApp in
if (inApp.properties.dismissForever &&
InAppUtils.is(inAppDismissForever: inApp)) {
//Dismiss Forever
} else {
InAppUtils.inAppWasShownWith(in: inApp) { inApp, error in
//did expired
} didShowMoreThanOnce: { inApp, error in
//show more than x times
} didClickOut: { inApp, error in
//click more than x times
} onSuccess: {
//show inApp
}
}
} errorLoad: { error in
//Show error
}
[[[InAppHandler alloc]init] getInApp:inAppId success:^(NSString *content, INInApp *inApp) {
if (inApp.properties.dismissForever &&
[InAppUtils isInAppDismissForever:inApp]){
//Dissmis Forever
} else {
[InAppUtils inAppWasShownWithInApp:inApp didExpired:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
//did expired
} didShowMoreThanOnce:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
//show more than x times
} didClickOut:^(INInApp * _Nonnull inApp, INError * _Nonnull error) {
//click more than x times
} onSuccess:^{
//show inApp
}];
}
} errorLoad:^(INError *error) {
//Show error
}];
For the case of what we call Dismiss Forever, once the action is performed, this method must be called:
InAppUtils.addNewInApp(toDismissForever: inApp)
[InAppUtils addNewInAppToDismissForever: inApp];
To send the statistics in the event that the inApp has been clicked and clicks out control:
InAppUtils.inAppWasTappedWith(inApp)
[InAppUtils inAppWasTappedWithInApp: inApp];
In the event that you would like to obtain the push object of type json to carry out checks or actions that your application requires, we leave you this code that will help to obtain it:
@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)")
- (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);
}
If you decide to treat the action of the Push independently without going through our SDK, once the push has been collected as explained in the previous section, in the userNotificationCenter: didReceive method of the AppDelegate itself, in order to record the statistics you must add the next method:
Indigitall.registerStatistics(response)
[Indigitall registesStatistics: response];
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 to be able to associate it with the custom ID that you associate to the device, similar to how here.
To perform the registration tasks, these two methods are used:
//User ID
Indigitall.logIn(withId: "YOUR_ID", onSuccess: { (device) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
//Disconnection
Indigitall.logOut(success: { (device) in
//DO SOMETHING
}, onError: { (error) in
//LOG ERROR
})
//User ID
[Indigitall logInWithId:"YOUR_ID" onSuccess:^(INDevice * _Nonnull device) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
//Disconnection
[Indigitall logOutWithSuccess:^(INDevice * _Nonnull device) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
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.
The token has a predetermined expiration date, once it has expired in our system, an event of type 'Protocol' will be launched, which will indicate said expiration and will have to return the configuration JSON. To collect the event, you have to implement it in the corresponding class, and override the following method:
class YOURCLASS: GetAuthConfig
func getAuthConfig() -> [AnyHashable : Any] {
...
return YOUR_JSON
}
@interface YOURCLASS: NSObject<GetAuthConfig>
- (NSDictionary *) getAuthConfig;
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 :
The notifications will also come with a 'read' status, to help differentiate those status.
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:
Inbox.getInboxWithSuccess({ (inbox) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
[Inbox getInboxWithSuccess:^(INInbox * _Nonnull inbox) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
Once the Inbox instance is obtained, we will use it to request the next page, which is made with the following method, in the event that there are no more pages it will indicate it in the error with code 410:
inbox.getNextPage(success: { (inbox, newNotifications) in
//DO SOMETHING
}) { (error) in
if (error.statusCode == 410){
//LOG NO MORE PAGES
}else{
//LOG ERROR
}
}
[inbox getNextPageWithSuccess:^(INInbox * _Nonnull inbox, NSArray<INInboxNotification *>* newNotifications) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
if (error.statusCode == 410){
//LOG NO MORE PAGES
}
//LOG ERROR
}];
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:
inbox.getInfoFromNotification(withSendingId: SENDING_ID, onSuccess: { (inboxnotification) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
[inbox getInfoFromNotificationWithSendingId:SENDING_ID onSuccess:^(INInboxNotification * _Nonnull inboxNotification) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
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:
//Modify a notification
inbox.modifyStatusFromNotification(withSendingId: SENDING_ID, status: STATUS, onSuccess: { (inboxnotification) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
//Massively modify
inbox.massiveEditNotifications(withSendingIdsList: [SENDING_IDS], status: STATUS, onSuccess: {
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
//Modify a notification
[inbox modifyStatusFromNotificationWithSendingId:SENDING_ID status:STATUS onSuccess:^(INInboxNotification * _Nonnull inboxNotification) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
//Massively modify
[inbox massiveEditNotificationsWithSendingIdsList:[SENDING_IDS] status:STATUS onSuccess:^{
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];
To find out the number of notifications in the Inbox according to their status, this method is performed:
Inbox.getMessagesCount(success: { (counter) in
//DO SOMETHING
}) { (error) in
//LOG ERROR
}
[Inbox getMessagesCountWithSuccess:^(INInboxCounters * _Nonnull counters) {
//DO SOMETHING
} onError:^(INError * _Nonnull error) {
//LOG ERROR
}];