{"_id":"58aad9dd8f862f250076fa0d","project":"54aa7f773b56130b0056c86e","user":"54aa7f3f9bb00c0b00cb899b","category":{"_id":"58aad9dd8f862f250076f9f8","project":"54aa7f773b56130b0056c86e","version":"58aad9dd8f862f250076f9f4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-05T12:44:00.338Z","from_sync":false,"order":4,"slug":"android-sdk","title":"Android SDK"},"parentDoc":null,"__v":0,"version":{"_id":"58aad9dd8f862f250076f9f4","project":"54aa7f773b56130b0056c86e","__v":2,"createdAt":"2017-02-20T11:58:21.765Z","releaseDate":"2017-02-20T11:58:21.765Z","categories":["58aad9dd8f862f250076f9f5","58aad9dd8f862f250076f9f6","58aad9dd8f862f250076f9f7","58aad9dd8f862f250076f9f8","58aad9dd8f862f250076f9f9","58aad9dd8f862f250076f9fa","58aad9dd8f862f250076f9fb","58ac26b3d460ce2500185d26"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"Locate","version_clean":"6.0.0","version":"6.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-12T09:59:09.778Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":17,"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 *startLocateSessionForAlias:* method, instead of *startLocateSession* on the *LocateManager*. You need to pass the unique client identifier as the parameter.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Tips\",\n  \"body\": \"• It is highly recommended to call the *startLocateSessionForAlias:* 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 *startLocateSesssionForAlias* every time the application runs. Most often it'll be the *application:onCreate:* method.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class MyApp extends LocateApp {\\n    private ILocateManager manager;\\n\\n    :::at:::Override\\n    public void onCreate() {\\n        super.onCreate();\\n        getLocateManager();\\n        if (user_logged_in)\\n            getLocateManager().startLocateSessionForAlias(\\\"my_user_alias\\\");\\n    }\\n\\n    public ILocateManager getLocateManager() {\\n        if (manager == null) {\\n            manager = LocateFactory.getInstance();\\n        }\\n        return manager;\\n    }\\n}\",\n      \"language\": \"java\"\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\": \"getLocateManager().logoutCurrentAlias(new ILocateLogoutCurrentUserListener() {\\n    @Override\\n    public void onLogout() {\\n        //Your code that should happen after logout      \\n    }\\n});\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"android-deduping-setting-the-customers-alias","type":"basic","title":"Android - Deduping - Setting the customer's alias"}

Android - 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 *startLocateSessionForAlias:* method, instead of *startLocateSession* on the *LocateManager*. You need to pass the unique client identifier as the parameter. [block:callout] { "type": "warning", "title": "Tips", "body": "• It is highly recommended to call the *startLocateSessionForAlias:* 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 *startLocateSesssionForAlias* every time the application runs. Most often it'll be the *application:onCreate:* method." } [/block] [block:code] { "codes": [ { "code": "public class MyApp extends LocateApp {\n private ILocateManager manager;\n\n @Override\n public void onCreate() {\n super.onCreate();\n getLocateManager();\n if (user_logged_in)\n getLocateManager().startLocateSessionForAlias(\"my_user_alias\");\n }\n\n public ILocateManager getLocateManager() {\n if (manager == null) {\n manager = LocateFactory.getInstance();\n }\n return manager;\n }\n}", "language": "java" } ] } [/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": "getLocateManager().logoutCurrentAlias(new ILocateLogoutCurrentUserListener() {\n @Override\n public void onLogout() {\n //Your code that should happen after logout \n }\n});", "language": "java" } ] } [/block]