Segmentation
This is an add-on feature of Notificare. You will need to subscribe to the Users & Authentication add-on and configure this service as described here. Once subscribed, before you can use this functionality, make sure you create User Preferences like explained here.
To get a list of preferences for a user, use the following method:
[[[NotificarePushLib shared] authManager] fetchUserPreferences:^(id _Nullable response, NSError * _Nullable error) {
if (!error) {
for (NotificareUserPreference * preference in response){
NSLog(@"%@", [preference preferenceLabel]);
}
}
}];
NotificarePushLib.shared().authManager().fetchUserPreferences({(_ response: Any?, _ error: Error?) -> Void in
if error == nil {
for preference: NotificareUserPreference in response {
print("\(preference.preferenceLabel())")
}
}
})
This method will return a list of all User Preferences created for your app. You can then add or remove users to/from segments in each preference.
To add a user to a segment in a preference, invoke the method below:
[[[NotificarePushLib shared] authManager] addSegment:seg toPreference:item completionHandler:^(id _Nullable response, NSError * _Nullable error) {
if (!error) {
//Segment added to preference
}
}];
NotificarePushLib.shared().authManager().addSegment(seg, toPreference: item, completionHandler: {(_ response: Any?, _ error: Error?) -> Void in
if error == nil {
//Segment added to preference
}
})
To remove a user from a segment in a preference, invoke the method below:
[[[NotificarePushLib shared] authManager] removeSegment:seg fromPreference:item completionHandler:^(id _Nullable response, NSError * _Nullable error) {
if (!error) {
//Segment remove from preference
}
}];
NotificarePushLib.shared().authManager().removeSegment(seg, fromPreference: item, completionHandler: {(_ response: Any?, _ error: Error?) -> Void in
if error == nil {
//Segment remove from preference
}
})
This functionality will allow you to categorize your users based on their preferences. You can then easily create campaigns using these segments.