{"_id":"564318f1f49bfa0d002f5566","user":"54aa7f3f9bb00c0b00cb899b","category":{"_id":"55781fe35129590d003ff4fb","version":"55781fe25129590d003ff4f7","__v":11,"pages":["55781fe45129590d003ff517","55781fe45129590d003ff518","55781fe45129590d003ff519","55781fe45129590d003ff51a","55781fe45129590d003ff51b","55781fe45129590d003ff51c","55781fe45129590d003ff51d","55781fe45129590d003ff51e","55781fe45129590d003ff51f","55781fe45129590d003ff520","55781fe45129590d003ff521","55781fe45129590d003ff522","5579ab5fc7fb3f2100096fad","55f7de1660cc850d008a7a22","55f7e1fbe32e9b0d00a2d4d0","561f72bacec1a50d00979598","561f764f61c0521700acc428","563337539c607719001b85dd","564318f1f49bfa0d002f5566","564f03454f000617007bd670","565ee80a23fd5f0d00a129f9","56793cd73473bc0d008e141b"],"project":"54aa7f773b56130b0056c86e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:43:51.897Z","from_sync":false,"order":3,"slug":"ios-sdk","title":"iOS SDK"},"parentDoc":null,"__v":16,"version":{"_id":"55781fe25129590d003ff4f7","project":"54aa7f773b56130b0056c86e","forked_from":"54aa7f773b56130b0056c871","__v":6,"createdAt":"2015-06-10T11:30:42.700Z","releaseDate":"2015-06-10T11:30:42.700Z","categories":["55781fe35129590d003ff4f8","55781fe35129590d003ff4f9","55781fe35129590d003ff4fa","55781fe35129590d003ff4fb","55781fe35129590d003ff4fc","55781fe35129590d003ff4fd","55781fe35129590d003ff4fe","564bbc7e8841060d00abb2ee","565b66c446118c0d00dcb0bb","56898269f8dc340d00308c13","582318b23b961a0f009516a1","594a848c9f4771001a43c959"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Developers","version_clean":"2.0.0","version":"2.0"},"githubsync":"","project":"54aa7f773b56130b0056c86e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-11T10:31:13.931Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":16,"body":"Deduping is the process of setting a unique identifier for a user as their customer alias, so that we can recognise when that user uses your app on multiple devices. Deduping helps to improve data quality by ensuring that the same user can have multiple devices added to their profile instead of different Pulsate profiles being created for each device. \n\nThe customer alias can be any identifier that you choose that will not change for that user. Customer Number is an example of a suitable identifier that would make a good alias because customer number is a parameter that is unlikely to change. Conversely, an email address is not a good choice as an identifier because there is a strong possibility that a user could change their email in the future. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Starting the session with alias\"\n}\n[/block]\nIn order to use the deduping feature, you need to use the *startPulsateSessionForAlias:* method, instead of *startPulsateSession* on the *PULPulsateManager*. You need to pass the unique client identifier as the parameter.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"• It is highly recommended to call the *startPulsateSessionForAlias:* method in the callback method of successful login response from your server.\\n\\n• Most apps don't require to log in every time the app gets restarted. Remember to call *startPulsateSesssionForAlias* every time the application runs. Most often it'll be the *application:didFinishLaunchingWithOptions:* method.\",\n  \"title\": \"Tips\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\n// Initializing Pulsate, and calling start session with alias *if* user is already logged in\\n- (BOOL)application:(UIApplication *)application\\n  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\\n    NSError* error;\\n\\n\\t\\tPULAuthorizationData* authData = [[PULAuthorizationData alloc] initWithAppId::::at:::\\\"YOUR_APP_ID\\\" andAppKey:@\\\"YOUR_APP_KEY\\\" validationError:&error];\\n    \\n    PULPulsateManager* pulsateManager = [PULPulsateFactory getInstanceWithAuthorizationData:authData withLocationEnabled:YES withPushEnabled:YES withLaunchOptions:launchOptions error:&error];\\n\\t\\t\\n    // Most apps don't require log in every time the app gets terminated\\n\\t\\t// Check if this is the case, if not, wait for successful server login response callback\\n\\t\\tif ( [self isUserLoggedIn] ) \\n\\t\\t{\\n\\t\\t\\t[pulsateManager startPulsateSessionForAlias:uniqueIdentifier withListener:^(BOOL success, NSError* error) {}];\\n    }\\n   \\n    return YES;\\n}\\n\\n// It's recommended to start session with alias after getting a successful login\\nresponse from your server\\n-(void)successfullyAuthorizedWithServerUser:(NSString*)uniqueIdentifier \\n{\\n    PULPulsateManager* pulsateManager = [PULPulsateFactory getDefaultInstance];\\n    [pulsateManager startPulsateSessionForAlias:uniqueIdentifier withListener:^(BOOL success, NSError* error) {}];\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Initializing Pulsate, and calling start session with alias *if* user is already logged in\\n\\nfunc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {\\n\\n    var error: NSError\\n    var authData: PULAuthorizationData = PULAuthorizationData(appId: \\\"YOUR_APP_ID\\\", andAppKey: \\\"YOUR_APP_KEY\\\", validationError: error)\\n    \\n    var pulsateManager = PULPulsateFactory.getInstanceWithAuthorizationData(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions, error: error)\\n    \\n    // Most apps don't require log in every time the app gets terminated\\n    // Check if this is the case, if not, wait for successful server login response callback\\n    if self.isUserLoggedIn() {\\n        pulsateManager.startPulsateSessionForAlias(uniqueIdentifier)\\n    }\\n    return true\\n}\\n\\n// It's recommended to start session with alias after getting a successful login response from your server\\nfunc successfullyAuthorizedWithServerUser(uniqueIdentifier: String) {\\n    var pulsateManager = PULPulsateFactory.getDefaultInstance()\\n    pulsateManager.startPulsateSessionForAlias(uniqueIdentifier)\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Logging out\"\n}\n[/block]\nIf your user logs out, in order for him to stop sending data and getting new campaigns you need to call the *logoutCurrentAlias* method. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[pulsateManager logout:^(BOOL success, NSError* error) {}];\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pulsateManager?.logout({(success, error) in });\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"deduping-setting-the-customers-alias","type":"basic","title":"Deduping - Setting the customer's alias"}

Deduping - Setting the customer's alias


Deduping is the process of setting a unique identifier for a user as their customer alias, so that we can recognise when that user uses your app on multiple devices. Deduping helps to improve data quality by ensuring that the same user can have multiple devices added to their profile instead of different Pulsate profiles being created for each device. The customer alias can be any identifier that you choose that will not change for that user. Customer Number is an example of a suitable identifier that would make a good alias because customer number is a parameter that is unlikely to change. Conversely, an email address is not a good choice as an identifier because there is a strong possibility that a user could change their email in the future. [block:api-header] { "type": "basic", "title": "Starting the session with alias" } [/block] In order to use the deduping feature, you need to use the *startPulsateSessionForAlias:* method, instead of *startPulsateSession* on the *PULPulsateManager*. You need to pass the unique client identifier as the parameter. [block:callout] { "type": "warning", "body": "• It is highly recommended to call the *startPulsateSessionForAlias:* method in the callback method of successful login response from your server.\n\n• Most apps don't require to log in every time the app gets restarted. Remember to call *startPulsateSesssionForAlias* every time the application runs. Most often it'll be the *application:didFinishLaunchingWithOptions:* method.", "title": "Tips" } [/block] [block:code] { "codes": [ { "code": "\n// Initializing Pulsate, and calling start session with alias *if* user is already logged in\n- (BOOL)application:(UIApplication *)application\n didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n NSError* error;\n\n\t\tPULAuthorizationData* authData = [[PULAuthorizationData alloc] initWithAppId:@\"YOUR_APP_ID\" andAppKey:@\"YOUR_APP_KEY\" validationError:&error];\n \n PULPulsateManager* pulsateManager = [PULPulsateFactory getInstanceWithAuthorizationData:authData withLocationEnabled:YES withPushEnabled:YES withLaunchOptions:launchOptions error:&error];\n\t\t\n // Most apps don't require log in every time the app gets terminated\n\t\t// Check if this is the case, if not, wait for successful server login response callback\n\t\tif ( [self isUserLoggedIn] ) \n\t\t{\n\t\t\t[pulsateManager startPulsateSessionForAlias:uniqueIdentifier withListener:^(BOOL success, NSError* error) {}];\n }\n \n return YES;\n}\n\n// It's recommended to start session with alias after getting a successful login\nresponse from your server\n-(void)successfullyAuthorizedWithServerUser:(NSString*)uniqueIdentifier \n{\n PULPulsateManager* pulsateManager = [PULPulsateFactory getDefaultInstance];\n [pulsateManager startPulsateSessionForAlias:uniqueIdentifier withListener:^(BOOL success, NSError* error) {}];\n}", "language": "objectivec" } ] } [/block] [block:code] { "codes": [ { "code": "// Initializing Pulsate, and calling start session with alias *if* user is already logged in\n\nfunc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {\n\n var error: NSError\n var authData: PULAuthorizationData = PULAuthorizationData(appId: \"YOUR_APP_ID\", andAppKey: \"YOUR_APP_KEY\", validationError: error)\n \n var pulsateManager = PULPulsateFactory.getInstanceWithAuthorizationData(authData, withLocationEnabled: true, withPushEnabled: true, withLaunchOptions: launchOptions, error: error)\n \n // Most apps don't require log in every time the app gets terminated\n // Check if this is the case, if not, wait for successful server login response callback\n if self.isUserLoggedIn() {\n pulsateManager.startPulsateSessionForAlias(uniqueIdentifier)\n }\n return true\n}\n\n// It's recommended to start session with alias after getting a successful login response from your server\nfunc successfullyAuthorizedWithServerUser(uniqueIdentifier: String) {\n var pulsateManager = PULPulsateFactory.getDefaultInstance()\n pulsateManager.startPulsateSessionForAlias(uniqueIdentifier)\n}", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "Logging out" } [/block] If your user logs out, in order for him to stop sending data and getting new campaigns you need to call the *logoutCurrentAlias* method. [block:code] { "codes": [ { "code": "[pulsateManager logout:^(BOOL success, NSError* error) {}];", "language": "objectivec" } ] } [/block] [block:code] { "codes": [ { "code": "pulsateManager?.logout({(success, error) in });", "language": "swift" } ] } [/block]