{ "id": "170732", "key": "TIMOB-25960", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2018-01-05T00:08:13.000+0000", "priority": null, "labels": [ "engReviewed", "hyperloop", "ios" ], "versions": [], "issuelinks": [], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2019-06-18T15:52:50.000+0000", "status": { "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", "name": "Reopened", "id": "4", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "Instead of strings, I only get functions that produce errors when processing the Hyperloop results. That said: console.log prints the correct value for the unmodified variable. I need to access the string that console.log prints.\r\n{code:js}\r\nvar HMHomeManager = require('HomeKit/HMHomeManager');\r\nvar NSArray = require('Foundation/NSArray');\r\n\t\r\nvar HMHomeManagerDelegate = Hyperloop.defineClass('HMHomeManagerDelegate', 'NSObject'); \r\n\t\r\nHMHomeManagerDelegate.addMethod({\r\n\tselector: 'homeManagerDidUpdateHomes:',\r\n\tinstance: true,\r\n\targuments: ['HMHomeManager'],\r\n\tcallback: function(sender) {\r\n\t\tif (this.homeManagerDidUpdateHomes) {\r\n\t\t\tthis.homeManagerDidUpdateHomes(sender);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nvar HMHome = require('HomeKit/HMHome');\t\t\r\n\r\nvar delegate = new HMHomeManagerDelegate();\r\ndelegate.homeManagerDidUpdateHomes = function(sender) {\r\n\t\r\n\tvar name = sender.primaryHome.name;\r\n\tconsole.log('name: '+ name);\r\n\tconsole.log(JSON.stringify({\"name\":\"name\",\"value\":name}));\r\n};\r\n\r\nvar homeManager = new HMHomeManager();\r\nhomeManager.delegate = delegate;\r\n{code}\r\nPrints:\r\n{code}\r\n[INFO] : name: My Home\r\n{code}\r\nShould print:\r\n{code}\r\n[INFO] : name: My Home\r\n[INFO] : {\"name\":\"name\",\"value\":\"My Home\"}\r\n{code}", "attachment": [ { "id": "63943", "filename": "HomeKitAccess.zip", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-10T20:32:49.000+0000", "size": 9299327, "mimeType": "application/zip" } ], "flagged": false, "summary": "Hyperloop: iOS - Property returns function instead of string ", "creator": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "subtasks": [], "reporter": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "environment": "MacOS, iOS, HomeKit, Appcelerator Studio 5.0.0", "comment": { "comments": [ { "id": "432822", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello [~aschräder],\r\nThanks for sharing with us. Can you please share a simple test case to reproduce this on our end. Also share your environment details.\r\nBest", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-01-07T11:11:03.000+0000", "updated": "2018-01-07T11:11:03.000+0000" }, { "id": "432840", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "Hi Mostafizur,\r\n\r\nI think the below code should be the minimal test case to reproduce the behaviour. Putting this into the index.js should produce the described behaviour:\r\n{code:js}\r\nvar HMHomeManager = require('HomeKit/HMHomeManager');\r\nvar NSArray = require('Foundation/NSArray');\r\n\t\r\nvar HMHomeManagerDelegate = Hyperloop.defineClass('HMHomeManagerDelegate', 'NSObject'); // also tried: ['HomeKit/HMHomeManagerDelegate'] or ['HMHomeManagerDelegate'] instead of manually adding the 'homeManagerDidUpdateHomes:', but that did not work\r\n\t\r\nHMHomeManagerDelegate.addMethod({\r\n\tselector: 'homeManagerDidUpdateHomes:',\r\n\tinstance: true,\r\n\targuments: ['HMHomeManager'],\r\n\tcallback: function(sender) {\r\n\t\tif (this.homeManagerDidUpdateHomes) {\r\n\t\t\tthis.homeManagerDidUpdateHomes(sender);\r\n\t\t}\r\n\t}\r\n});\r\n\r\nvar HMHome = require('HomeKit/HMHome');\t\t\r\n\r\nvar delegate = new HMHomeManagerDelegate();\r\ndelegate.homeManagerDidUpdateHomes = function(sender) {\r\n\tvar homes = [\r\n\t\t{name: sender.primaryHome.name, uuid: sender.primaryHome.uniqueIdentifier}\r\n\t];\r\n\tvar name = homes[0].name;\r\n\tconsole.log('name: '+ name);\r\n\tconsole.log('name: '+name.toString);\r\n\tconsole.log('name: '+JSON.stringify(\r\n\t\t{\"name\":\"name\",\"value\":name}\r\n\t));\r\n};\r\n\r\nvar homeManager = new HMHomeManager();\r\nhomeManager.delegate = delegate;\r\n{code}\r\n\r\nWith regards to environment details: MacOS, iOS, HomeKit, Appcelerator Studio 5.0.0. (all the latest versions). The hyperloop module is activated. As build properties I have selected the Titanium SDK 6.3.0.GA. in the tiapp.xml I have configured the necessary properties and entitlements: \r\n{code:xml}\r\n \r\n \r\n \r\n com.apple.developer.homekit\r\n \r\n com.apple.external-accessory.wireless-configuration\r\n \r\n \r\n \r\n true\r\n true\r\n \r\n NSHomeKitUsageDescription\r\n Switch needs access to your HomeKit devices.\r\n \r\n \r\n \r\n{code}\r\nHope this helps reproducing the behaviour. In case anything is missing, please let me know.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-08T12:19:03.000+0000", "updated": "2018-01-10T22:29:37.000+0000" }, { "id": "432864", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Please create a sample Alloy project with the reproducible code and attach the file in here. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2018-01-08T18:27:54.000+0000", "updated": "2018-01-08T18:27:54.000+0000" }, { "id": "432913", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "This is not a Hyperloop issue, please read the native documentation more carefully. I see this kind of issues popping up more and more. Some background for your issue:\r\n\r\n- The issue is in {{uuid}}, not {{name}}\r\n- {{uniqueIdentifier}} returns a {{UUID}} instance, not String as documented [here|https://developer.apple.com/documentation/homekit/hmhome/1620243-uniqueidentifier]\r\n- Access it as a String by using {{uniqueIdentifier.uuidString}} as documented [here|https://developer.apple.com/documentation/foundation/uuid/1779712-uuidstring]\r\n- {{toString}} is no property but a function (e.g. {{toString()}}). It is no native method but a JavaScript method that only works with proper JavaScript types like {{Number}} and {{Array}} as documented [here|https://www.w3schools.com/jsref/jsref_tostring_number.asp]", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-09T14:21:38.000+0000", "updated": "2018-01-09T14:21:38.000+0000" }, { "id": "432990", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "Please reopen the issue as this has nothing to do with the uniqueIdentifier or the use of toString(). I have cleaned the case description in order to avoid distraction - albeit at the cost that the error message disappears and the problem only occurs 'silently'.\r\n\r\nsender.primaryHome.name is a string and does not behave as a string would.\r\n\r\n@Hans Knöchel: while your explanations around the UUID are what I would expect based on the documentation, the evidence is that console.log with uniqueIdentifier.uuidString prints 'undefined' whereas console.log with uniqueIdentifier prints the actual value.\r\n", "updateAuthor": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-10T20:51:19.000+0000", "updated": "2018-01-10T20:51:19.000+0000" }, { "id": "432991", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "@Sharif AbuDarda: I have attached a sample project 'HomeKitAccess' as you suggested.", "updateAuthor": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-10T20:53:36.000+0000", "updated": "2018-01-10T20:53:36.000+0000" }, { "id": "432995", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~aschräder] The Obj-C usage (which Hyperloop is generated from) is {{UUIDString}}, not {{uuidString}} which is [documented|https://developer.apple.com/documentation/foundation/nsuuid/1416585-uuidstring?language=objc] as well. And the reason why {{sender.primaryHome.name}} prints correctly is likely because it prints the description as the native world does as well. If Hyperloop really unwraps this correctly, you should still be able to receive it via {{sender.primaryHome.name.description}}. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-10T22:28:46.000+0000", "updated": "2018-01-10T22:28:46.000+0000" }, { "id": "433000", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "@Hans Knöchel Thanks for the prompt response. I had copied the {code:java} uuidString {code} from your prior post, but the result with {code:java}UUIDString {code} is exactly the same.\r\n\r\nI've tested the your hypothesis with regards to the description. It turns out that Hyperloop apparently does not unwrap this as expected. With {code:java}sender.primaryHome.name.description {code} it prints:\r\n{code:java}\r\n[INFO] : name: undefined\r\n[INFO] : {\"name\":\"name\"}\r\n{code}\r\n\r\nInterestingly, this is the same as result that I get with {code:java}UUIDString {code}. I could understand why the description of the {code:java}name {code} property prints {code:java}name {code} , but why would {code:java}sender.primaryHome.uniqueIdentifier.UUIDString {code} print {code:java}name {code} ?\r\n\r\nI take advantage and address another problem I encounter, which may be related: I seem to be unable to access an array (an {code:java}NSArray {code} ) with Hyperloop. If I define name as any of the three below properties:\r\n{code:java}\r\nsender.homes[0].name\r\nsender.homes.objectAtIndex(0).name\r\nsender.homes.count\r\n{code}\r\nit prints nothing at all. \r\n\r\nI hope it's just me coding it incorrectly. Otherwise it would be hard to implement a HomeKit app without improvements in Hyperloop... \r\n ", "updateAuthor": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-11T00:11:11.000+0000", "updated": "2018-01-11T00:11:11.000+0000" }, { "id": "433587", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "@Shak Hossain: Can you please re-open this issue? This is neither invalid nor resolved! Thanks!", "updateAuthor": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-01-24T13:26:25.000+0000", "updated": "2018-01-24T13:26:25.000+0000" }, { "id": "436630", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello [~aschräder],\r\n\r\nCan you test the issue on latest SDK and let us know how it goes.", "updateAuthor": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "created": "2018-04-09T11:16:27.000+0000", "updated": "2018-04-09T11:16:27.000+0000" }, { "id": "436683", "author": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "body": "I have just tested it with 7.1.0 - and the result is unchanged. The problem continues to exist and needs to be fixed.\r\nAndreas", "updateAuthor": { "name": "aschräder", "key": "aschräder", "displayName": "Andreas Schräder", "active": true, "timeZone": "Europe/Madrid" }, "created": "2018-04-10T01:07:15.000+0000", "updated": "2018-04-10T01:07:15.000+0000" }, { "id": "436825", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey there! We will further investigate this and I have moved it to TIMOB. We will let you know once it's scheduled.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-04-12T08:21:36.000+0000", "updated": "2018-04-12T08:21:36.000+0000" } ], "maxResults": 16, "total": 16, "startAt": 0 } } }