{"_id":"5bbd6e97598b2e0003c9d209","project":"55e67aaa9cc7c62b00c4a1ea","version":{"_id":"5b720760c44b7600034b7a08","project":"55e67aaa9cc7c62b00c4a1ea","__v":0,"forked_from":"5b1f2cbdfd653400031d8d9f","createdAt":"2015-09-02T04:27:23.612Z","releaseDate":"2015-09-02T04:27:23.612Z","categories":["5b720760c44b7600034b79a7","5b720760c44b7600034b79a8","5b720760c44b7600034b79a9","5b720760c44b7600034b79aa","5b720760c44b7600034b79ab","561c61b4ad272c0d00a892df","586c014c0abf1d0f000d04d4","58991d2ad207df0f0002186b","5b720760c44b7600034b79ac","5b720760c44b7600034b79ad","5af0fe494ca2730003cbc98a","5af0fe55ec80af0003804ca2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"API V6","version_clean":"1.4.0","version":"1.4"},"category":{"_id":"5b720760c44b7600034b79ac","project":"55e67aaa9cc7c62b00c4a1ea","__v":0,"version":"5b720760c44b7600034b7a08","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-02-08T21:31:11.878Z","from_sync":false,"order":6,"slug":"advanced-techniques","title":"Advanced Techniques"},"user":"5b0b7a46a26e6400036604fd","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-10-10T03:14:31.897Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"Sailthru Profile Vars can be set and retrieved through the SDK.\n\nWhen setting vars they should be configured in JSON object format:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Setup profile vars object\\nNSDictionary *profileVars = :::at:::{\\n    @\\\"string_key\\\" : @\\\"string_value\\\",\\n    @\\\"object_key\\\" : @{},\\n    @\\\"boolean_key\\\" : @YES\\n};\\n    \\n// Set profile vars\\n[Carnival setProfileVars:profileVars withResponse:^(NSError * _Nullable error) {\\n    // Check if error is non-nil for result\\n}];\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS (Objective-C)\"\n    },\n    {\n      \"code\": \"// Setup profile vars object\\nlet profileVars : [String : Any] = [ \\n  \\t\\\"string_key\\\" : \\\"string_value\\\",\\n\\t\\t\\\"object_key\\\" : [],\\n\\t\\t\\\"boolean_key\\\" : true \\n]\\n\\n// Set profile vars\\nCarnival.setProfileVars(profileVars) { (error : Error?) in\\n\\t\\t// Check if error is non-nil for result\\n}\",\n      \"language\": \"swift\",\n      \"name\": \"iOS (Swift)\"\n    },\n    {\n      \"code\": \"// Setup profile vars object\\nJSONObject profileVars = new JSONObject();\\nprofileVars.put(\\\"string_key\\\", \\\"string_value\\\");\\nprofileVars.put(\\\"object_key\\\", new JSONObject());\\nprofileVars.put(\\\"boolean_key\\\", true);\\n\\n// Set profile vars\\nCarnival.setProfileVars(profileVars, new Carnival.CarnivalHandler<Void>() {\\n    @Override\\n    public void onSuccess(Void value) {\\n        // Handle success\\n    }\\n\\n    @Override\\n    public void onFailure(Error error) {\\n        // Handle error\\n    }\\n});\",\n      \"language\": \"java\",\n      \"name\": \"Android (Java)\"\n    },\n    {\n      \"code\": \"// Setup profile vars object\\nvar profileVars = {\\n\\t\\\"string_key\\\" : \\\"string_value\\\",\\n\\t\\\"object_key\\\" : {},\\n\\t\\\"boolean_key\\\": true\\n};\\n\\n// Set profile vars\\nCarnival.setProfileVars(profileVars).then(result => {\\n  // Handle success\\n}).catch(e => {\\n  // Handle error\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"React Native (JavaScript)\"\n    }\n  ]\n}\n[/block]\nWhen retrieving vars they will be returned in the JSON object format:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Carnival getProfileVarsWithResponse:^(NSDictionary<NSString *,id> * _Nullable profileVars, NSError * _Nullable error) {\\n    // Handle profileVars object or error\\n}];\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS (Objective-C)\"\n    },\n    {\n      \"code\": \"Carnival.getProfileVars { (profileVars : [String : Any]?, error : Error?) in\\n\\t\\t// Handle profileVars object or error\\n}\",\n      \"language\": \"swift\",\n      \"name\": \"iOS (Swift)\"\n    },\n    {\n      \"code\": \"Carnival.getProfileVars(new Carnival.CarnivalHandler<JSONObject>() {\\n    @Override\\n    public void onSuccess(JSONObject profileVars) {\\n\\t\\t\\t\\t// Handle profileVars object\\n    }\\n\\n    @Override\\n    public void onFailure(Error error) {\\n        // Handle error\\n    }\\n});\",\n      \"language\": \"java\",\n      \"name\": \"Android (Java)\"\n    },\n    {\n      \"code\": \"Carnival.getProfileVars().then(profileVars => {\\n\\t// Handle profileVars object\\n}).catch(e => {\\n\\t// Handle error\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"React Native (JavaScript)\"\n    }\n  ]\n}\n[/block]","excerpt":"How to use Sailthru Profile Vars from the SDK","slug":"sailthru-profile-vars","type":"basic","title":"Sailthru Profile Vars"}

Sailthru Profile Vars

How to use Sailthru Profile Vars from the SDK

Sailthru Profile Vars can be set and retrieved through the SDK. When setting vars they should be configured in JSON object format: [block:code] { "codes": [ { "code": "// Setup profile vars object\nNSDictionary *profileVars = @{\n @\"string_key\" : @\"string_value\",\n @\"object_key\" : @{},\n @\"boolean_key\" : @YES\n};\n \n// Set profile vars\n[Carnival setProfileVars:profileVars withResponse:^(NSError * _Nullable error) {\n // Check if error is non-nil for result\n}];", "language": "objectivec", "name": "iOS (Objective-C)" }, { "code": "// Setup profile vars object\nlet profileVars : [String : Any] = [ \n \t\"string_key\" : \"string_value\",\n\t\t\"object_key\" : [],\n\t\t\"boolean_key\" : true \n]\n\n// Set profile vars\nCarnival.setProfileVars(profileVars) { (error : Error?) in\n\t\t// Check if error is non-nil for result\n}", "language": "swift", "name": "iOS (Swift)" }, { "code": "// Setup profile vars object\nJSONObject profileVars = new JSONObject();\nprofileVars.put(\"string_key\", \"string_value\");\nprofileVars.put(\"object_key\", new JSONObject());\nprofileVars.put(\"boolean_key\", true);\n\n// Set profile vars\nCarnival.setProfileVars(profileVars, new Carnival.CarnivalHandler<Void>() {\n @Override\n public void onSuccess(Void value) {\n // Handle success\n }\n\n @Override\n public void onFailure(Error error) {\n // Handle error\n }\n});", "language": "java", "name": "Android (Java)" }, { "code": "// Setup profile vars object\nvar profileVars = {\n\t\"string_key\" : \"string_value\",\n\t\"object_key\" : {},\n\t\"boolean_key\": true\n};\n\n// Set profile vars\nCarnival.setProfileVars(profileVars).then(result => {\n // Handle success\n}).catch(e => {\n // Handle error\n});", "language": "javascript", "name": "React Native (JavaScript)" } ] } [/block] When retrieving vars they will be returned in the JSON object format: [block:code] { "codes": [ { "code": "[Carnival getProfileVarsWithResponse:^(NSDictionary<NSString *,id> * _Nullable profileVars, NSError * _Nullable error) {\n // Handle profileVars object or error\n}];", "language": "objectivec", "name": "iOS (Objective-C)" }, { "code": "Carnival.getProfileVars { (profileVars : [String : Any]?, error : Error?) in\n\t\t// Handle profileVars object or error\n}", "language": "swift", "name": "iOS (Swift)" }, { "code": "Carnival.getProfileVars(new Carnival.CarnivalHandler<JSONObject>() {\n @Override\n public void onSuccess(JSONObject profileVars) {\n\t\t\t\t// Handle profileVars object\n }\n\n @Override\n public void onFailure(Error error) {\n // Handle error\n }\n});", "language": "java", "name": "Android (Java)" }, { "code": "Carnival.getProfileVars().then(profileVars => {\n\t// Handle profileVars object\n}).catch(e => {\n\t// Handle error\n});", "language": "javascript", "name": "React Native (JavaScript)" } ] } [/block]