{"_id":"56c41905c39ff40d00d25f98","project":"56bc8e679afb8b0d00d62dcf","parentDoc":null,"__v":13,"user":"56b98db7bb36440d0001f492","version":{"_id":"56bc8e689afb8b0d00d62dd2","project":"56bc8e679afb8b0d00d62dcf","__v":18,"createdAt":"2016-02-11T13:36:40.146Z","releaseDate":"2016-02-11T13:36:40.146Z","categories":["56bc8e689afb8b0d00d62dd3","56c3c837bc41330d009f25ed","56c3c83e521f350d00d348eb","56c3c8452d97560d00e23cd8","56c3c85234df460d00c2beb8","56c4180d70187b17005f43b4","56c418162d97560d00e23cf6","56c4181cc4796b0d007ef039","56c4182370187b17005f43b5","56c418292e75e01700986052","56c4183328bd680d005e7ac6","56c4183bbb64720d00552b88","56c418414040602b0064cea0","56c4184754b6030d00ec29a1","56c4184c28bd680d005e7ac7","56c4185370187b17005f43b6","56c4185b6063071700500cfc","582a98b6f8c0a0190053d7a5"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"56c418162d97560d00e23cf6","__v":3,"pages":["56c41905c39ff40d00d25f98","56c41911c4796b0d007ef03c","56c4191cbb64720d00552b89"],"project":"56bc8e679afb8b0d00d62dcf","version":"56bc8e689afb8b0d00d62dd2","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-02-17T06:49:58.871Z","from_sync":false,"order":0,"slug":"device-information","title":"Device Information"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-17T06:53:57.903Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"/devices\"\n}\n[/block]\nRegisters and authenticates a device with Buddy.  \n\nIn doing so, this call authenticates a device's ability to communicate with Buddy, and is responsible for validating your app's **appID** and **appKey**, which were previously created at [https://buddyplatform.com](https://buddyplatform.com).\n\nTo ensure that a specific device has a unique registration across calls to Buddy for the associated app, be sure to use the uniqueId parameter.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var options = {\\n\\tappID: \\\"bbbbbc.DdHBvgIhKgDn\\\",\\n\\tappKey: \\\"12FFF34-1234-1234-G234-123FFF\\\",\\n\\tplatform: \\\"iOS\\\",\\n\\tpushToken: \\\"my-SP3C14L-puSH-t0k3n\\\",\\n\\tappVersion: \\\"1.11\\\",\\n\\tosVersion: \\\"10\\\",\\n\\tuniqueId: \\\"GHBQ332-lwkfjeqWE31-USEaGUID\\\",\\n\\tmodel: \\\"iPhone 6\\\",\\n\\tconnectionType: \\\"WiFi\\\",\\n\\tlocation: \\\"47.1, -121.292\\\"\\n};\\n\\nBuddy.post('/devices',\\n\\t\\toptions,\\n\\t\\tfunction(err, result) {\\n\\t\\t\\t \\n\\t\\t\\tif (result.success) {\\n\\t\\t\\t\\t// Do something with the result!\\n\\t\\t\\t} else { \\n\\t\\t\\t\\t// Otherwise log the error\\n\\t\\t\\t\\tconsole.log(err); \\n\\t\\t\\t} \\n\\t\\t}\\n\\t);\",\n      \"language\": \"javascript\"\n    },\n    {\n      \"code\": \"NSDictionary *params = :::at:::{\\n\\t\\t\\[email protected]\\\"appID\\\": @\\\"bbbbbc.DdHBvgIhKgDn\\\",\\n\\t\\t\\[email protected]\\\"appKey\\\": @\\\"12FFF34-1234-1234-G234-123FFF\\\",\\n\\t\\t\\[email protected]\\\"platform\\\": @\\\"iOS\\\",\\n\\t\\t\\[email protected]\\\"pushToken\\\": @\\\"my-SP3C14L-puSH-t0k3n\\\",\\n\\t\\t\\[email protected]\\\"appVersion\\\": @\\\"1.11\\\",\\n\\t\\t\\[email protected]\\\"osVersion\\\": @\\\"10\\\",\\n\\t\\t\\[email protected]\\\"uniqueId\\\": @\\\"GHBQ332-lwkfjeqWE31-USEaGUID\\\",\\n\\t\\t\\[email protected]\\\"model\\\": @\\\"iPhone 6\\\",\\n\\t\\t\\[email protected]\\\"connectionType\\\": @\\\"WiFi\\\",\\n\\t\\t\\[email protected]\\\"location\\\": BPCoordinateMake(47.1, -121.292)\\n\\t\\t};\\n\\n[Buddy POST:@\\\"/devices\\\" parameters:params class:[NSDictionary class] callback:^(id obj, NSError *error) {\\n\\t// Your callback code here\\n}];\",\n      \"language\": \"objectivec\",\n      \"name\": \"iOS\"\n    },\n    {\n      \"code\": \"Map<String, Object> parameters = new HashMap<String, Object>();\\nparameters.put(\\\"appID\\\", \\\"bbbbbc.DdHBvgIhKgDn\\\");\\nparameters.put(\\\"appKey\\\", \\\"12FFF34-1234-1234-G234-123FFF\\\");\\nparameters.put(\\\"platform\\\", \\\"iOS\\\");\\nparameters.put(\\\"pushToken\\\", \\\"my-SP3C14L-puSH-t0k3n\\\");\\nparameters.put(\\\"appVersion\\\", \\\"1.11\\\");\\nparameters.put(\\\"osVersion\\\", \\\"10\\\");\\nparameters.put(\\\"uniqueId\\\", \\\"GHBQ332-lwkfjeqWE31-USEaGUID\\\");\\nparameters.put(\\\"model\\\", \\\"iPhone 6\\\");\\nparameters.put(\\\"connectionType\\\", \\\"WiFi\\\");\\nparameters.put(\\\"location\\\", myLocation);\\n\\nBuddy.<JsonObject>post(\\\"/devices\\\", parameters, new BuddyCallback<JsonObject>(JsonObject.class) {\\n\\[email protected]\\n\\tpublic void completed(BuddyResult<JsonObject> result) {\\n\\t\\t// Your callback code here\\n\\t}\\n});\",\n      \"language\": \"java\",\n      \"name\": \"Android\"\n    },\n    {\n      \"code\": \"var options = new {\\n\\t\\t\\tappID = \\\"bbbbbc.DdHBvgIhKgDn\\\",\\n\\t\\t\\tappKey = \\\"12FFF34-1234-1234-G234-123FFF\\\",\\n\\t\\t\\tplatform = \\\"iOS\\\",\\n\\t\\t\\tpushToken = \\\"my-SP3C14L-puSH-t0k3n\\\",\\n\\t\\t\\tappVersion = \\\"1.11\\\",\\n\\t\\t\\tosVersion = \\\"10\\\",\\n\\t\\t\\tuniqueId = \\\"GHBQ332-lwkfjeqWE31-USEaGUID\\\",\\n\\t\\t\\tmodel = \\\"iPhone 6\\\",\\n\\t\\t\\tconnectionType = \\\"WiFi\\\",\\n\\t\\t\\tlocation = new BuddyGeoLocation(47.1, -122.3)\\n\\t\\t};\\n\\nvar result = await Buddy.PostAsync<IDictionary<string,object>>(\\\"/devices\\\", options);\",\n      \"language\": \"csharp\",\n      \"name\": \".NET\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"appID\",\n    \"0-1\": \"The application ID previously obtained when the app was registered at the Buddy Developer Dashboard.\",\n    \"1-0\": \"appKey\",\n    \"1-1\": \"The application key that was previously obtained when the application was registered in the Buddy Developer Dashboard.\",\n    \"2-0\": \"platform\",\n    \"2-1\": \"The platform name for this device. Can be set to any string which describes the device/platform such as \\\"iOS\\\", \\\"Android\\\", \\\"Windows Phone\\\", \\\"Windows\\\", etc.\\n\\nNote: While arbitrary strings are permitted, in order to take advantage of push notifications the following convention should be observed:\\n\\n  * `iOS` Send push notifications using Apple APN\\n  * `WindowsPhone` Send push notifications using Microsoft WNS\\n  * `Android` Send push notifications using Google GCM\",\n    \"3-0\": \"pushToken\",\n    \"3-1\": \"A platform-specific token used for push notifications on this device.\",\n    \"4-0\": \"appVersion\",\n    \"4-1\": \"The version of the app installed on this device.\",\n    \"5-0\": \"osVersion\",\n    \"5-1\": \"The version of the OS installed on this device.\",\n    \"6-0\": \"uniqueId\",\n    \"6-1\": \"A unique identifier which can be used by the application for this device. **Using uniqueId is important to ensure that the device uses the same device registration across calls to Buddy for the associated app.**\",\n    \"7-0\": \"model\",\n    \"7-1\": \"The model of the device such as \\\"iPhone 5\\\" or \\\"Samsung Galaxy S3\\\". Can be set to any string which describes the model.\",\n    \"8-0\": \"connectionType\",\n    \"8-1\": \"Indicates the type of network connection being used by the device. Options are \\\"Unknown\\\", \\\"Carrier\\\" and \\\"Wifi\\\".\",\n    \"9-0\": \"location\",\n    \"9-1\": \"A location value, passed as a string in the format \\\"`{latitude},{longitude}`\\\" (e.g. `\\\"47.1,-121.292\\\"`).\",\n    \"0-2\": \"string\",\n    \"1-2\": \"string\",\n    \"2-2\": \"string\",\n    \"3-2\": \"string\",\n    \"4-2\": \"string\",\n    \"5-2\": \"string\",\n    \"6-2\": \"string\",\n    \"7-2\": \"string\",\n    \"8-2\": \"string\",\n    \"9-2\": \"string\",\n    \"0-3\": \"Required\",\n    \"1-3\": \"Required\",\n    \"2-3\": \"Required\",\n    \"3-3\": \"Optional\",\n    \"4-3\": \"Optional\",\n    \"5-3\": \"Optional\",\n    \"6-3\": \"Optional\",\n    \"7-3\": \"Optional\",\n    \"8-3\": \"Optional\",\n    \"9-3\": \"Optional\"\n  },\n  \"cols\": 4,\n  \"rows\": 10\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"status\\\": 201,\\n    \\\"result\\\": {\\n        \\\"serviceRoot\\\": \\\"https://api.buddyplatform.com\\\",\\n        \\\"accessToken\\\": \\\"[access token>]\\\",\\n        \\\"accessTokenExpires\\\": \\\"/Date(1416775578992)/\\\"\\n    },\\n    \\\"request_id\\\": \\\"7f02b95c-840e-4d82-9440-95af85398dbb\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Response\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]","excerpt":"","slug":"register-device","type":"basic","title":"Register Device"}
[block:api-header] { "type": "post", "title": "/devices" } [/block] Registers and authenticates a device with Buddy. In doing so, this call authenticates a device's ability to communicate with Buddy, and is responsible for validating your app's **appID** and **appKey**, which were previously created at [https://buddyplatform.com](https://buddyplatform.com). To ensure that a specific device has a unique registration across calls to Buddy for the associated app, be sure to use the uniqueId parameter. [block:code] { "codes": [ { "code": "var options = {\n\tappID: \"bbbbbc.DdHBvgIhKgDn\",\n\tappKey: \"12FFF34-1234-1234-G234-123FFF\",\n\tplatform: \"iOS\",\n\tpushToken: \"my-SP3C14L-puSH-t0k3n\",\n\tappVersion: \"1.11\",\n\tosVersion: \"10\",\n\tuniqueId: \"GHBQ332-lwkfjeqWE31-USEaGUID\",\n\tmodel: \"iPhone 6\",\n\tconnectionType: \"WiFi\",\n\tlocation: \"47.1, -121.292\"\n};\n\nBuddy.post('/devices',\n\t\toptions,\n\t\tfunction(err, result) {\n\t\t\t \n\t\t\tif (result.success) {\n\t\t\t\t// Do something with the result!\n\t\t\t} else { \n\t\t\t\t// Otherwise log the error\n\t\t\t\tconsole.log(err); \n\t\t\t} \n\t\t}\n\t);", "language": "javascript" }, { "code": "NSDictionary *params = @{\n\t\t\[email protected]\"appID\": @\"bbbbbc.DdHBvgIhKgDn\",\n\t\t\[email protected]\"appKey\": @\"12FFF34-1234-1234-G234-123FFF\",\n\t\t\[email protected]\"platform\": @\"iOS\",\n\t\t\[email protected]\"pushToken\": @\"my-SP3C14L-puSH-t0k3n\",\n\t\t\[email protected]\"appVersion\": @\"1.11\",\n\t\t\[email protected]\"osVersion\": @\"10\",\n\t\t\[email protected]\"uniqueId\": @\"GHBQ332-lwkfjeqWE31-USEaGUID\",\n\t\t\[email protected]\"model\": @\"iPhone 6\",\n\t\t\[email protected]\"connectionType\": @\"WiFi\",\n\t\t\[email protected]\"location\": BPCoordinateMake(47.1, -121.292)\n\t\t};\n\n[Buddy POST:@\"/devices\" parameters:params class:[NSDictionary class] callback:^(id obj, NSError *error) {\n\t// Your callback code here\n}];", "language": "objectivec", "name": "iOS" }, { "code": "Map<String, Object> parameters = new HashMap<String, Object>();\nparameters.put(\"appID\", \"bbbbbc.DdHBvgIhKgDn\");\nparameters.put(\"appKey\", \"12FFF34-1234-1234-G234-123FFF\");\nparameters.put(\"platform\", \"iOS\");\nparameters.put(\"pushToken\", \"my-SP3C14L-puSH-t0k3n\");\nparameters.put(\"appVersion\", \"1.11\");\nparameters.put(\"osVersion\", \"10\");\nparameters.put(\"uniqueId\", \"GHBQ332-lwkfjeqWE31-USEaGUID\");\nparameters.put(\"model\", \"iPhone 6\");\nparameters.put(\"connectionType\", \"WiFi\");\nparameters.put(\"location\", myLocation);\n\nBuddy.<JsonObject>post(\"/devices\", parameters, new BuddyCallback<JsonObject>(JsonObject.class) {\n\[email protected]\n\tpublic void completed(BuddyResult<JsonObject> result) {\n\t\t// Your callback code here\n\t}\n});", "language": "java", "name": "Android" }, { "code": "var options = new {\n\t\t\tappID = \"bbbbbc.DdHBvgIhKgDn\",\n\t\t\tappKey = \"12FFF34-1234-1234-G234-123FFF\",\n\t\t\tplatform = \"iOS\",\n\t\t\tpushToken = \"my-SP3C14L-puSH-t0k3n\",\n\t\t\tappVersion = \"1.11\",\n\t\t\tosVersion = \"10\",\n\t\t\tuniqueId = \"GHBQ332-lwkfjeqWE31-USEaGUID\",\n\t\t\tmodel = \"iPhone 6\",\n\t\t\tconnectionType = \"WiFi\",\n\t\t\tlocation = new BuddyGeoLocation(47.1, -122.3)\n\t\t};\n\nvar result = await Buddy.PostAsync<IDictionary<string,object>>(\"/devices\", options);", "language": "csharp", "name": ".NET" } ], "sidebar": true } [/block] [block:parameters] { "data": { "0-0": "appID", "0-1": "The application ID previously obtained when the app was registered at the Buddy Developer Dashboard.", "1-0": "appKey", "1-1": "The application key that was previously obtained when the application was registered in the Buddy Developer Dashboard.", "2-0": "platform", "2-1": "The platform name for this device. Can be set to any string which describes the device/platform such as \"iOS\", \"Android\", \"Windows Phone\", \"Windows\", etc.\n\nNote: While arbitrary strings are permitted, in order to take advantage of push notifications the following convention should be observed:\n\n * `iOS` Send push notifications using Apple APN\n * `WindowsPhone` Send push notifications using Microsoft WNS\n * `Android` Send push notifications using Google GCM", "3-0": "pushToken", "3-1": "A platform-specific token used for push notifications on this device.", "4-0": "appVersion", "4-1": "The version of the app installed on this device.", "5-0": "osVersion", "5-1": "The version of the OS installed on this device.", "6-0": "uniqueId", "6-1": "A unique identifier which can be used by the application for this device. **Using uniqueId is important to ensure that the device uses the same device registration across calls to Buddy for the associated app.**", "7-0": "model", "7-1": "The model of the device such as \"iPhone 5\" or \"Samsung Galaxy S3\". Can be set to any string which describes the model.", "8-0": "connectionType", "8-1": "Indicates the type of network connection being used by the device. Options are \"Unknown\", \"Carrier\" and \"Wifi\".", "9-0": "location", "9-1": "A location value, passed as a string in the format \"`{latitude},{longitude}`\" (e.g. `\"47.1,-121.292\"`).", "0-2": "string", "1-2": "string", "2-2": "string", "3-2": "string", "4-2": "string", "5-2": "string", "6-2": "string", "7-2": "string", "8-2": "string", "9-2": "string", "0-3": "Required", "1-3": "Required", "2-3": "Required", "3-3": "Optional", "4-3": "Optional", "5-3": "Optional", "6-3": "Optional", "7-3": "Optional", "8-3": "Optional", "9-3": "Optional" }, "cols": 4, "rows": 10 } [/block] [block:code] { "codes": [ { "code": "{\n \"status\": 201,\n \"result\": {\n \"serviceRoot\": \"https://api.buddyplatform.com\",\n \"accessToken\": \"[access token>]\",\n \"accessTokenExpires\": \"/Date(1416775578992)/\"\n },\n \"request_id\": \"7f02b95c-840e-4d82-9440-95af85398dbb\"\n}", "language": "json", "name": "Response" } ], "sidebar": true } [/block]