{ "id": "172441", "key": "TIMOB-26483", "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": [ { "id": "20128", "name": "Hyperloop 3.2.0", "archived": true, "released": false } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-11-01T20:02:39.000+0000", "created": "2018-10-15T14:53:39.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "20270", "name": "Hyperloop 3.1.3", "archived": false, "released": true } ], "issuelinks": [], "assignee": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-11-08T23:11:40.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" }, { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "*Steps to reproduce the behavior*\r\n{code}\r\nconst HKHealthStore = require('HealthKit/HKHealthStore');\r\nconsole.log(`isHealthDataAvailable: ${HKHealthStore.isHealthDataAvailable()}`);\r\n{code}\r\n\r\n*Actual behavior*\r\nThe build fails with a linker error due to usage of symbols that are not available on iOS\r\n\r\n*Expected behavior*\r\nThe build is successful and HealthKit is usable via Hyperloop", "attachment": [ { "id": "65719", "filename": ".log", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-15T14:53:46.000+0000", "size": 4146209, "mimeType": "text/plain" }, { "id": "65720", "filename": "diagnostic3820464935909926844.log", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-15T14:53:57.000+0000", "size": 498754, "mimeType": "text/plain" } ], "flagged": false, "summary": "Hyperloop - iOS: Exclude platform unsupported methods from metabase", "creator": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Appcelerator Studio 5.0.0", "comment": { "comments": [ { "id": "442904", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Both should work but it appears there is an issue with certain parts of the HealthKit framework only being available on watchOS.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-10-24T14:58:44.000+0000", "updated": "2018-10-24T14:58:44.000+0000" }, { "id": "442907", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "if I try:\r\n\r\nvar HealthKit = require('HealthKit/HKHealthStore');\r\n\r\nget the info after try to compile directly in Xcode\r\nHKWorkoutSession' is unavailable: not available on iOS/\r\n\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-24T15:27:15.000+0000", "updated": "2018-10-24T15:27:15.000+0000" }, { "id": "442908", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Yes, that's exactly the issue we will fix in this ticket. Sorry, there is currently no workaround for that.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-10-24T16:39:50.000+0000", "updated": "2018-10-24T16:39:50.000+0000" }, { "id": "442910", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The workaround ist possible by open HealthKit.m in an Xcode editor and delete the lines after hyperloop does its compiling and before Xcode compiling\r\n\r\nNot good but possible.\r\n\r\nNevertheless I struggle with the next steps. Maybe you can help:\r\n\r\n console.log (HKHealthStore.isHealthDataAvailable());\r\n var healthStore = new HKHealthStore;\r\n console.log (healthStore.bloodType());\r\n\r\nbut get always \r\n\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 39;\r\n[ERROR] : line = 24;\r\n[ERROR] : message = \"healthStore.bloodType is not a function. (In 'healthStore.bloodType()', 'healthStore.bloodType' is undefined)\";\r\n[ERROR] : sourceURL = \"file:///Users/mollin/Library/Developer/CoreSimulator/Devices/AD860109-8C75-46A2-985F-098761AA8475/data/Containers/Bundle/Application/117FCE39-3893-4EF9-9045-F395564C02F4/mcx%20alexa.app/ui/common/app_ui_healthkit.js\";\r\n[ERROR] : stack = \" at start@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/AD860109-8C75-46A2-985F-098761AA8475/data/Containers/Bundle/Application/117FCE39-3893-4EF9-9045-F395564C02F4/mcx%20alexa.app/ui/common/app_ui_healthkit.js:24:39)\\n at global code@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/AD860109-8C75-46A2-985F-098761AA8475/data/Containers/Bundle/Application/117FCE39-3893-4EF9-9045-F395564C02F4/mcx%20alexa.app/app.js:35:20)\";\r\n[ERROR] : }\r\n\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-24T16:49:58.000+0000", "updated": "2018-10-24T16:49:58.000+0000" }, { "id": "442912", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Well, that works, but it's very unpractical since you always need to change it if the hyperloop code is regenerated.\r\n\r\nAnyway, to continiue you need to look at the Objcetive-C API, you used is the Swift method name. It should be something like {{healthStore.bloodTypeWithError(null)}}\r\n\r\n", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-10-24T17:00:32.000+0000", "updated": "2018-10-24T17:00:32.000+0000" }, { "id": "442915", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks for help;\r\nas I'm not familiar with object-c. I am able to use simple functions as you describe. Can you help me to implement \r\n\r\n- (void)requestAuthorizationToShareTypes:(NSSet *)typesToShare \r\n readTypes:(NSSet *)typesToRead \r\n completion:(void (^)(BOOL success, NSError *error))completion;\r\n\r\nI always get the info that requestAuthorizationToShareTypes is not a function\r\n\r\nwould be very helpful as I have soon a presentation for apple healthcare people in Germany\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-24T18:43:44.000+0000", "updated": "2018-10-24T18:43:44.000+0000" }, { "id": "442951", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Please read the docs and check the hyperloop-examples app which should point you in the right direction. You will have to create the {{NSSet}} instances, fill them with the types you want and then you should be able to call {{healthStore.requestAuthorizationToShareTypesReadTypesCompletion(typesToShare, typesToRead, function(success, error) {})}}. I can answer to your specific questions but i cannot provide a complete working example.\r\n\r\nHowever, i'm working on a fix for the internal Hyperloop issue so you don't have to patch files manually.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-10-25T15:32:06.000+0000", "updated": "2018-10-25T15:32:06.000+0000" }, { "id": "443009", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Jan,\r\nthanks for that help. Although its not easy to patch Hyperloop files manually, I was able to call the method without getting an error.\r\n\r\nThe only problem is to get the typesToShare and typesToRead.\r\n\r\nI tried this under others but got null as result\r\n\r\nvar readTypes = [require('HealthKit/HKObjectType').HKCharacteristicTypeIdentifierDateOfBirth];\r\n \r\nMaybe some last hint from you how to solve\r\n\r\nBest regards\r\nJoachim Mollin\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-27T13:50:50.000+0000", "updated": "2018-10-27T13:50:50.000+0000" }, { "id": "443050", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hyperloop does not automatically convert between js arrays and the native counterparts because there are just too many possible target classes that act as collections. Instead you have to explicitly create an {{NSSet}} or {{NSMutableSet}} as you would in Objective-C.\r\n\r\n{code:js}\r\nconst HKObjectType = require('HealthKit/HKObjectType');\r\nconst HKQuantityTypeIdentifierBodyMassIndex = require('HealthKit').HKQuantityTypeIdentifierBodyMassIndex;\r\nconst typesToWrite = new NSMutableSet(); // short for NSMutableSet.alloc().init()\r\ntypesToWrite.addObject(HKObjectType.characteristicTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex));\r\n// ...\r\n{code}", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-10-30T03:12:59.000+0000", "updated": "2018-11-01T16:55:48.000+0000" }, { "id": "443198", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tried again a lot. Ended up with this error. What am I doing wrong?\r\n\r\n const HKObjectType = require('HealthKit/HKObjectType');\r\n const HKQuantityTypeIdentifierBodyMassIndex = require('HealthKit/HKQuantityType');\r\n const NSMutableSet = require('Foundation/NSMutableSet');\r\n const typesToWrite = new NSMutableSet(); // short for NSMutableSet.alloc().init()\r\n typesToWrite.addObject(HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex));\r\n\r\ngot always this\r\n[ERROR] : *** -[__NSSetM addObject:]: object cannot be nil\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 26;\r\n[ERROR] : description = \"*** -[__NSSetM addObject:]: object cannot be nil\";\r\n[ERROR] : line = 121;\r\n[ERROR] : message = \"*** -[__NSSetM addObject:]: object cannot be nil\";\r\n[ERROR] : name = NSInvalidArgumentException;\r\n[ERROR] : nativeStack = \"1 libobjc.A.dylib 0x0000000107be3735 objc_exception_throw + 48\\n2 CoreFoundation 0x0000000108d344ec _CFThrowFormattedException + 194\\n3 CoreFoundation 0x0000000108d58191 -[__NSSetM addObject:] + 801\\n4 CoreFoundation 0x0000000108def03c __invoking___ + 140\\n5 CoreFoundation 0x0000000108dec4d5 -[NSInvocation invoke] + 325\\n6 mcx alexa 0x0000000101f2b5ae +[HyperloopUtils invokeSelector:args:target:instance:] + 1550\\n7 mcx alexa 0x0000000101f20261 Dispatch + 1489\\n8 JavaScriptCore 0x00000001023d6b9f _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 495\\n9 ??? 0x00002e668ce0102d 0x0 + 51017985036333\\n10 JavaScriptCore 0x00000001023ab33d llint_entry + 26817\\n11 JavaScriptCore 0x00000001023ab33d llint_entry + 26817\\n12 JavaScriptCore 0x00000001023ab33d llint_entry + 26817\\n13 JavaScriptCore 0x00000001023a48fe vmEntryToJavaScript + 244\\n14 JavaScriptCore 0x000000010289f36a _ZN3JSC11Interpreter14executeProgramERKNS_10SourceCodeEPNS_9ExecStateEPNS_8JSObjectE + 11178\\n15 JavaScriptCore 0x0000000102acaa20 _ZN3JSC8evaluateEPNS_9ExecStateERKNS_10SourceCodeENS_7JSValueERN3WTF8NakedPtrINS_9ExceptionEEE + 288\\n16 JavaScriptCore 0x00000001023d5ff5 JSEvaluateScript + 501\\n17 mcx alexa 0x0000000101c0ac22 -[KrollBridge evalFileOnThread:context:] + 1314\\n18 mcx alexa 0x0000000101c10b7c -[KrollInvocation invoke:] + 124\\n19 mcx alexa 0x0000000101c121e3 -[KrollContext invoke:] + 163\\n20 mcx alexa 0x0000000101c125a9 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 169\\n21 mcx alexa 0x0000000101c0ada4 -[KrollBridge evalFile:callback:selector:] + 116\\n22 mcx alexa 0x0000000101c0bc38 -[KrollBridge didStartNewContext:] + 2600\\n23 mcx alexa 0x0000000101c12e9a -[KrollContext main] + 1834\\n24 mcx alexa 0x0000000101c11fb7 __21-[KrollContext start]_block_invoke + 39\\n25 libdispatch.dylib 0x000000010a2fc4e1 _dispatch_call_block_and_release + 12\\n26 libdispatch.dylib 0x000000010a2fd54b _dispatch_client_callout + 8\\n27 libdispatch.dylib 0x000000010a309380 _dispatch_main_queue_callback_4CF + 1290\\n28 CoreFoundation 0x0000000108d4d3e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\\n29 CoreFoundation 0x0000000108d47a76 __CFRunLoopRun + 2342\\n30 CoreFoundation 0x0000000108d46e11 CFRunLoopRunSpecific + 625\\n31 GraphicsServices 0x000000010cf6b1dd GSEventRunModal + 62\\n32 UIKitCore 0x000000011469881d UIApplicationMain + 140\\n33 mcx alexa 0x0000000101bf7316 main + 102\\n34 libdyld.dylib 0x000000010a36d575 start + 1\\n35 ??? 0x0000000000000001 0x0 + 1\";\r\n[ERROR] : sourceURL = \"file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/68251458-80CB-4767-B2E4-8E1D31B04D8F/mcx%20alexa.app/hyperloop/foundation/nsmutableset.js\";\r\n[ERROR] : stack = \" at dispatch@[native code]\\n at value@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/68251458-80CB-4767-B2E4-8E1D31B04D8F/mcx%20alexa.app/hyperloop/foundation/nsmutableset.js:121:26)\\n at start@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/68251458-80CB-4767-B2E4-8E1D31B04D8F/mcx%20alexa.app/ui/common/app_ui_healthkit.js:36:25)\\n at global code@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/68251458-80CB-4767-B2E4-8E1D31B04D8F/mcx%20alexa.app/app.js:35:20)\";\r\n[ERROR] : }\r\n\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-01T17:32:21.000+0000", "updated": "2018-11-01T17:32:21.000+0000" }, { "id": "443200", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "See my edit in my comment above. This line\r\n{code:js}\r\nconst HKQuantityTypeIdentifierBodyMassIndex = require('HealthKit/HKQuantityType');\r\n{code}\r\nshould be this\r\n{code:js}\r\nconst HKQuantityTypeIdentifierBodyMassIndex = require('HealthKit').HKQuantityTypeIdentifierBodyMassIndex;\r\n{code}\r\n\r\nPlease also see the [hyperloop-examples|https://github.com/appcelerator/hyperloop-examples] how to properly require types from native frameworks.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-01T17:53:43.000+0000", "updated": "2018-11-01T17:53:43.000+0000" }, { "id": "443201", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "yes, I changed it already to\r\n\r\n const HKObjectType = require('HealthKit/HKObjectType');\r\n const HKQuantityTypeIdentifierBodyMassIndex = require('HealthKit').HKQuantityTypeIdentifierBodyMassIndex;\r\n const NSMutableSet = require('Foundation/NSMutableSet');\r\n const typesToWrite = new NSMutableSet(); // short for NSMutableSet.alloc().init()\r\n typesToWrite.addObject(HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex));\r\n\r\n epr.fct.iDebug(typesToWrite);\r\n var completition = function (finished){};\r\n var auth = epr.healthkit.healthStore.requestAuthorizationToShareTypesReadTypesCompletion(typesToWrite, typesToWrite, completition);\r\n epr.fct.iDebug(auth);\r\n\r\nmy debug values are:\r\n\r\n[\r\n\r\nMeans typesToWrite are set, but auth returns null\r\n ", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-01T17:58:18.000+0000", "updated": "2018-11-01T17:58:18.000+0000" }, { "id": "443204", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "That's because the function does return void, see https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorizationtosharetypes?language=objc\r\n\r\nUse the completion callback and check the {{success}} parameter.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-01T19:59:50.000+0000", "updated": "2018-11-01T20:00:40.000+0000" }, { "id": "443205", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/hyperloop.next/pull/309", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-01T20:02:31.000+0000", "updated": "2018-11-01T20:02:31.000+0000" }, { "id": "443228", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "sorry, but get a 404 with this link", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-02T10:08:20.000+0000", "updated": "2018-11-02T10:08:20.000+0000" }, { "id": "443235", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "You can't view the PR because the Hyperloop source repo is private.\r\n\r\nHowever you can get the latest 3.2.0 beta build that includes the fix for this issue here: https://github.com/appcelerator-modules/hyperloop-builds/releases/tag/v3.2.0-beta.2\r\n\r\n", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-02T12:06:12.000+0000", "updated": "2018-11-02T12:06:12.000+0000" }, { "id": "443236", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hallo Jan,\r\nThanks for your help and patient. The connection to HealthKit is working. Hope I didn't nee more help.\r\nJoachim", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-02T12:08:38.000+0000", "updated": "2018-11-02T12:08:38.000+0000" }, { "id": "443259", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi,\r\nI can write Sample to Apple HealthKit but problems to read them back. Everything ist accepted until I want to execute the query.\r\nHope you can help.\r\n\r\nI tried building the query with 3 different methods:\r\n\r\nVersion 1 -> App starts but closed immediately. No error occurred\r\nVersion 3 -> the same. All debugs were shown\r\n\r\nFor version 2 I got:\r\n-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 26;\r\n[ERROR] : description = \"-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40\";\r\n[ERROR] : line = 133;\r\n[ERROR] : message = \"-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40\";\r\n[ERROR] : name = NSInvalidArgumentException;\r\n[ERROR] : nativeStack = \"1 libobjc.A.dylib 0x000000010c390735 objc_exception_throw + 48\\n2 CoreFoundation 0x000000010d5a4f44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132\\n3 CoreFoundation 0x000000010d58aed6 ___forwarding___ + 1446\\n4 CoreFoundation 0x000000010d58cda8 _CF_forwarding_prep_0 + 120\\n5 HealthKit 0x000000010c007263 -[HKHealthStore executeQuery:activationHandler:] + 315\\n6 CoreFoundation 0x000000010d58d03c __invoking___ + 140\\n7 CoreFoundation 0x000000010d58a4d5 -[NSInvocation invoke] + 325\\n8 mcx alexa 0x00000001065d948e +[HyperloopUtils invokeSelector:args:target:instance:] + 1550\\n9 mcx alexa 0x00000001065ce141 Dispatch + 1489\\n10 JavaScriptCore 0x0000000106a85b9f _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 495\\n11 ??? 0x00003d75e6e0102d 0x0 + 67576593911853\\n12 JavaScriptCore 0x0000000106a5a33d llint_entry + 26817\\n13 JavaScriptCore 0x0000000106a5a33d llint_entry + 26817\\n14 JavaScriptCore 0x0000000106a5a33d llint_entry + 26817\\n15 JavaScriptCore 0x0000000106a538fe vmEntryToJavaScript + 244\\n16 JavaScriptCore 0x0000000106f4e36a _ZN3JSC11Interpreter14executeProgramERKNS_10SourceCodeEPNS_9ExecStateEPNS_8JSObjectE + 11178\\n17 JavaScriptCore 0x0000000107179a20 _ZN3JSC8evaluateEPNS_9ExecStateERKNS_10SourceCodeENS_7JSValueERN3WTF8NakedPtrINS_9ExceptionEEE + 288\\n18 JavaScriptCore 0x0000000106a84ff5 JSEvaluateScript + 501\\n19 mcx alexa 0x00000001062b8492 -[KrollBridge evalFileOnThread:context:] + 1314\\n20 mcx alexa 0x00000001062be3ec -[KrollInvocation invoke:] + 124\\n21 mcx alexa 0x00000001062bfa53 -[KrollContext invoke:] + 163\\n22 mcx alexa 0x00000001062bfe19 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 169\\n23 mcx alexa 0x00000001062b8614 -[KrollBridge evalFile:callback:selector:] + 116\\n24 mcx alexa 0x00000001062b94a8 -[KrollBridge didStartNewContext:] + 2600\\n25 mcx alexa 0x00000001062c070a -[KrollContext main] + 1834\\n26 mcx alexa 0x00000001062bf827 __21-[KrollContext start]_block_invoke + 39\\n27 libdispatch.dylib 0x000000010ea904e1 _dispatch_call_block_and_release + 12\\n28 libdispatch.dylib 0x000000010ea9154b _dispatch_client_callout + 8\\n29 libdispatch.dylib 0x000000010ea9d380 _dispatch_main_queue_callback_4CF + 1290\\n30 CoreFoundation 0x000000010d4eb3e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\\n31 CoreFoundation 0x000000010d4e5a76 __CFRunLoopRun + 2342\\n32 CoreFoundation 0x000000010d4e4e11 CFRunLoopRunSpecific + 625\\n33 GraphicsServices 0x00000001128d51dd GSEventRunModal + 62\\n34 UIKitCore 0x0000000118d4581d UIApplicationMain + 140\\n35 mcx alexa 0x00000001062a4b86 main + 102\\n36 libdyld.dylib 0x000000010eb01575 start + 1\\n37 ??? 0x0000000000000001 0x0 + 1\";\r\n[ERROR] : sourceURL = \"file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E27FAF59-4BF6-462E-9BC9-9C3C390FC2A1/mcx%20alexa.app/hyperloop/healthkit/hkhealthstore.js\";\r\n[ERROR] : stack = \" at dispatch@[native code]\\n at value@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E27FAF59-4BF6-462E-9BC9-9C3C390FC2A1/mcx%20alexa.app/hyperloop/healthkit/hkhealthstore.js:133:26)\\n at readParameterItem@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E27FAF59-4BF6-462E-9BC9-9C3C390FC2A1/mcx%20alexa.app/ui/common/app_ui_healthkit.js:241:47)\\n at global code@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E27FAF59-4BF6-462E-9BC9-9C3C390FC2A1/mcx%20alexa.app/app.js:231:29)\";\r\n[ERROR] : }\r\n\r\n\r\nCode:\r\n //sampleType = HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryEnergyConsumed)\r\n var HKSampleType = require('HealthKit/HKSampleType');\r\n var sampleType = HKSampleType.quantityTypeForIdentifier(require('HealthKit').HKQuantityTypeIdentifierBodyMass);\r\n epr.fct.iDebug(HKSampleType); epr.fct.iDebug(sampleType); epr.fct.iDebug(\"END SAMPLETYPE\");\r\n \r\n //let predicate = HKQuery.predicateForSamplesWithStartDate(startDate, endDate: endDate, options: .None)\r\n var HKQuery = require('HealthKit/HKQuery');\r\n var predicate = HKQuery.predicateForSamplesWithStartDateEndDateOptions(startDate, endDate, null);\r\n epr.fct.iDebug(predicate); epr.fct.iDebug(\"END PREDICAT\");\r\n \r\n //Sort\r\n //NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];\r\n var HKSort = require('Foundation/NSSortDescriptor');\r\n var sortDesc = new HKSort(require('HealthKit').HKSampleSortIdentifierEndDate,true);\r\n epr.fct.iDebug(sortDesc); epr.fct.iDebug(\"END SORT\");\r\n \r\n //init(sampleType: HKSampleType,predicate: NSPredicate?,limit: Int,sortDescriptors: [NSSortDescriptor]?,resultsHandler: @escaping (HKSampleQuery, [HKSample]?, Error?) -> Void)\r\n var HKSampleQuery = require('HealthKit/HKSampleQuery');\r\n epr.fct.iDebug(HKSampleQuery);\r\n //version 1\r\n var query = HKSampleQuery.alloc().init(sampleType, predicate, require('HealthKit').HKObjectQueryNoLimit, sortDesc, fctResult);\r\n \r\n //version 2\r\n //var query = new HKSampleQuery(sampleType, predicate, require('HealthKit').HKObjectQueryNoLimit, sortDesc, fctResult);\r\n \r\n //version 3\r\n /*q = new HKSampleQuery();\r\n q.sampleType = sampleType;\r\n q.predicate = predicate;\r\n q.limit = require('HealthKit').HKObjectQueryNoLimit;\r\n q.sortDescriptors = sortDesc;\r\n q.resultsHandler = fctResult;\r\n epr.fct.iDebug(q);\r\n query = q;*/\r\n \r\n epr.fct.iDebug(query); epr.fct.iDebug(\"END query\");\r\n \r\n var ok = epr.hk.healthStore.executeQuery(query);\r\n epr.fct.iDebug(\"END EXECUTE\");\r\n\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-04T17:49:38.000+0000", "updated": "2018-11-04T17:49:38.000+0000" }, { "id": "443260", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This error is shown in the Simulator\r\n\r\n/hkhealthstore.js:133\r\n\t\t\tvar result = $dispatch(this.$native, 'executeQuery:', [_query], true);\r\n ^\r\n-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x6000031760d0\r\n at dispatch@[native code]\r\n at value@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/13AC1432-F4BC-4508-A72F-1FAC5A7CE127/mcx%20alexa.app/hyperloop/healthkit/hkhealthstore.js:133:26)\r\n at readParameterItem@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/13AC1432-F4BC-4508-A72F-1FAC5A7CE127/mcx%20alexa.app/ui/common/app_ui_healthkit.js:241:47)\r\n at global code@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/13AC1432-F4BC-4508-A72F-1FAC5A7CE127/mcx%20alexa.app/app.js:231:29)\r\n\r\n4 mcx alexa 0x000000010c9b13ec -[KrollInvocation invoke:] + 124\r\n5 mcx alexa 0x000000010c9b2a53 -[KrollContext invoke:] + 163\r\n6 mcx alexa 0x000000010c9b2e19 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 169\r\n7 mcx alexa 0x000000010c9ab614 -[KrollBridge evalFile:callback:selector:] + 116\r\n8 mcx alexa 0x000000010c9ac4a8 -[KrollBridge didStartNewContext:] + 2600\r\n9 mcx alexa 0x000000010c9b370a -[KrollContext main] + 1834\r\n10 mcx alexa 0x000000010c9b2827 __21-[KrollContext start]_block_invoke + 39\r\n11 libdispatch.dylib 0x000000011509e4e1 _dispatch_call_block_and_release + 12\r\n12 libdispatch.dylib 0x000000011509f54b _dispatch_client_callout + 8\r\n13 libdispatch.dylib 0x00000001150ab380 _dispatch_main_queue_callback_4CF + 1290\r\n14 CoreFoundation 0x0000000113aef3e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\r\n15 CoreFoundation 0x0000000113ae9a76 __CFRunLoopRun + 2342\r\n16 CoreFoundation 0x0000000113ae8e11 CFRunLoopRunSpecific + 625\r\n17 GraphicsServices0x0000000118ee31dd GSEventRunModal + 62\r\n18 UIKitCore 0x000000011f43d81d UIApplicationMain + 140\r\n19 mcx alexa 0x000000010c997b86 main + 102", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-04T18:03:06.000+0000", "updated": "2018-11-04T18:03:06.000+0000" }, { "id": "443291", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Again, you need to use the correct native functions! You use {{HKSampleQuery.alloc().init(}} or {{new HKSampleQuery()}}, but that is the default initializer provided by {{NSobject}}. Check the docs at https://developer.apple.com/documentation/healthkit/hksamplequery?language=objc and use the appropriate initializer.", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-05T15:16:53.000+0000", "updated": "2018-11-05T15:16:53.000+0000" }, { "id": "443293", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Sorry Jan,\r\nof course I'm not a object-c developer and maybe I'm stupid or blind but I follow exactly the example from Apple\r\n\r\nHKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:sampleType predicate:predicate limit:HKObjectQueryNoLimit sortDescriptors:nil resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {....\r\n\r\nor the example of old Ti.HealthKit module\r\nHKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType: [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]\r\n predicate: predicate\r\n limit: limit\r\n sortDescriptors: @[endDateSort]\r\n resultsHandler:^(HKSampleQuery *query, NSArray* results, NSError *error){\r\n NSLog(@\"SHAPERACE LOG: getSteps method with error = %@\", error);\r\n [self sendStepsData: results];\r\n if (completionHandler) completionHandler();\r\n }];\r\n\r\nmeans using the class HKSampleQuery and initialize with the prepared items\r\n\r\nSo what's the appropriate initializer \r\n\r\nvar query = new HKSampleQuery(sampleType, predicate, require('HealthKit').HKObjectQueryNoLimit, sortDesc, fctResult);\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-05T16:50:45.000+0000", "updated": "2018-11-05T16:50:45.000+0000" }, { "id": "443294", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "See the [Named Methods|https://docs.appcelerator.com/platform/latest/#!/guide/iOS_Hyperloop_Programming_Guide-section-src-46253491_iOSHyperloopProgrammingGuide-Namedmethods] section in the [Hyperloop iOS Guide|https://docs.appcelerator.com/platform/latest/#!/guide/iOS_Hyperloop_Programming_Guide]. Every named parameter in Objective-C becomes part of the method name in JavaScript. Hyperloop will remove the colons, capitalize the first letter of every parameter name and form the final method name from that.\r\n\r\nIn your case {{initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:}} becomes\r\n{{initWithSampleTypePredicateLimitSortDescriptorsResultsHandler(sampleType, predicate, HKObjectQueryNoLimit, sortDesc, fctResult)}}", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-05T17:04:57.000+0000", "updated": "2018-11-05T17:05:30.000+0000" }, { "id": "443296", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "you are right, I understood that constructions but \r\n\r\ninitWithSampleTypePredicateLimitSortDescriptorsResultsHandler is not a function/method in any class", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-05T17:23:42.000+0000", "updated": "2018-11-05T17:23:42.000+0000" }, { "id": "443301", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Have you tried {{HKSampleQuery.alloc().initWithSampleTypePredicateLimitSortDescriptorsResultsHandler(sampleType, predicate, HKObjectQueryNoLimit, sortDesc, callback);}} ?", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-05T19:50:08.000+0000", "updated": "2018-11-05T19:50:08.000+0000" }, { "id": "443302", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "yes, I have tried this besides many other things.\r\n\r\nWith your example I get the message, that .alloc().initWithSampleTypePredicateLimitSortDescriptorsResultsHandler is not a function\r\n\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 97;\r\n[ERROR] : line = 226;\r\n[ERROR] : message = \"HKSampleQuery.alloc().initWithSampleTypePredicateLimitSortDescriptorsResultHandler is not a function. (In 'HKSampleQuery.alloc().initWithSampleTypePredicateLimitSortDescriptorsResultHandler(sampleType, predicate, require(\\\"/hyperloop/healthkit/healthkit\\\").HKObjectQueryNoLimit, sortDesc, fctResult)', 'HKSampleQuery.alloc().initWithSampleTypePredicateLimitSortDescriptorsResultHandler' is undefined)\";\r\n[ERROR] : sourceURL = \"file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E4FB6019-9B3C-4B2E-BDDC-ED87918D806A/mcx%20alexa.app/ui/common/app_ui_healthkit.js\";\r\n[ERROR] : stack = \" at readParameterItem@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E4FB6019-9B3C-4B2E-BDDC-ED87918D806A/mcx%20alexa.app/ui/common/app_ui_healthkit.js:226:97)\\n at global code@file:///Users/mollin/Library/Developer/CoreSimulator/Devices/80119195-156D-4879-8609-9CE5FDD6FF33/data/Containers/Bundle/Application/E4FB6019-9B3C-4B2E-BDDC-ED87918D806A/mcx%20alexa.app/app.js:231:29)\";\r\n[ERROR] : }\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-05T20:17:53.000+0000", "updated": "2018-11-05T20:17:53.000+0000" }, { "id": "443303", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Check the spelling, you are missing an \"s\" in ...Result{color:red}s{color}Handler", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-05T20:21:15.000+0000", "updated": "2018-11-05T20:21:15.000+0000" }, { "id": "443304", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "shit. I didn't checked that. Sorry.\r\n\r\nNow get a result. Not what I expected but an error as result.\r\n\r\n var fctResult = function (query, sample, error){\r\n epr.fct.iDebug(\"GET BACK with read\");\r\n epr.fct.iDebug(query);\r\n epr.fct.iDebug(sample);\r\n epr.fct.iDebug(error);\r\n epr.fct.iDebug ('*****************************');\r\n };\r\n \r\n\r\ngives\r\n[INFO] : GET BACK with read\r\n[INFO] : \r\n[INFO] : \r\n[INFO] : Error Domain=NSCocoaErrorDomain Code=4099 \"The connection to service named com.apple.healthd.server was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.\" UserInfo={NSDebugDescription=The connection to service named com.apple.healthd.server was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid.}\r\n[INFO] : *****************************\r\n[INFO] : 1\r\n\r\nWhat ever it means\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-05T20:35:22.000+0000", "updated": "2018-11-05T20:35:22.000+0000" }, { "id": "443374", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "ok. now works\r\n\r\nerror was produced by \r\nvar HKSort = require('Foundation/NSSortDescriptor');\r\nvar sortDesc = new HKSort(require('HealthKit').HKSampleSortIdentifierEndDate,true);\r\nsetting sortDesc = null\r\n\r\ngives back an object in variable sample. This should be an array following apple HealthKit documentation\r\n\r\nin TI its a KrollBack object. How to convert to a JS structure?\r\n ", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-07T19:12:10.000+0000", "updated": "2018-11-07T19:12:10.000+0000" }, { "id": "443380", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I tried to cast as a NSObject\r\n\r\nvar fctResult = function (query, sampleObj, error){\r\n epr.fct.iDebug(\"GET BACK with read\");\r\n epr.fct.iDebug(query);\r\n epr.fct.iDebug(sampleObj);\r\n epr.fct.iDebug(error);\r\n epr.fct.iDebug ('*****************************');\r\n epr.fct.iDebug (typeof sampleOrg);\r\n \r\n var sample = require('Foundation/NSArray').cast(sampleObj);\r\n\r\nbut no change\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-07T21:06:20.000+0000", "updated": "2018-11-07T21:06:20.000+0000" }, { "id": "443382", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~mollin], please use proper code formatting, your posts are very hard to follow. So what's the output of your code? What's the issue with {{sampleObj}}? Can't you call {{sampleObj.objectAtIndex(0)}} on it, for example?", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-07T22:53:01.000+0000", "updated": "2018-11-07T22:53:01.000+0000" }, { "id": "443428", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Jan, yes, I can access the object and can extract the 1st part, which itself is an object.\r\n\r\n epr.fct.iDebug(sampleObj);\r\n epr.fct.iDebug (typeof sampleObj+\" SampleObj\"); \r\ngives the result \r\n(\r\n \"80 kg 641BEE94-6B6E-4B70-B8B7-A0DA4D3BC5DE \\\"mcx alexa\\\" (1.3), \\\"iPhone9,1\\\" (12.1) (2018-11-02 18:52:00 +0100 - 2018-11-02 18:52:00 +0100)\",\r\n\"80 kg CB6080A5-0AE7-4B30-B044-7CE5D8D4079F \\\"mcx alexa\\\" (1.3), \\\"iPhone9,1\\\" (12.1) (2018-11-02 18:54:24 +0100 - 2018-11-02 18:54:24 +0100)\",\r\n\"80 kg C9F9DBE6-6A95-45F2-8239-6AB25D5A3268 \\\"mcx alexa\\\" (1.3), \\\"iPhone9,1\\\" (12.1) (2018-11-02 18:55:34 +0100 - 2018-11-02 18:55:34 +0100)\",\r\n\"78 kg 1CD18E7C-E770-4DB9-A0E3-6E4F99330136 \\\"mcx alexa\\\" (1.3), \\\"iPhone9,1\\\" (12.1) (2018-11-02 19:07:56 +0100 - 2018-11-02 19:07:56 +0100)\"\r\n)\r\nobject SampleObj\r\n \r\n var sample = sampleObj.objectAtIndex(0);\r\n epr.fct.iDebug(typeof sample+\" - Sample\");\r\n epr.fct.iDebug(sample);\r\n epr.fct.iDebug(sample.toString); \r\ngives the result\r\nobject - Sample\r\n80 kg 641BEE94-6B6E-4B70-B8B7-A0DA4D3BC5DE \"mcx alexa\" (1.3), \"iPhone9,1\" (12.1) (2018-11-02 18:52:00 +0100 - 2018-11-02 18:52:00 +0100)\r\n\r\n\r\n var part = sample.objectAtIndex(0); gives then the error\r\nJS exception encountered calling callback: sample.objectAtIndex is not a function. (In 'sample.objectAtIndex(0)', 'sample.objectAtIndex' is undefined)\r\n\r\nI also tried to iterate with for (x in sample) through the object. But there is no chance to extract the other parts of the object.\r\n\r\napple says in documentation that sampleObj should be an array, I guess an NSArray. Can I cast it, as I already tried with no success.\r\n\r\nregards\r\nJoachim\r\n\r\n", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T17:56:36.000+0000", "updated": "2018-11-08T17:56:36.000+0000" }, { "id": "443429", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "sorry for the format. I tried to work with tab indents, but after sending they are gone", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T17:58:11.000+0000", "updated": "2018-11-08T17:58:11.000+0000" }, { "id": "443430", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "What makes you think the first object you get from the array is also a NSArray? According to the docs it is of type [HKSample|https://developer.apple.com/documentation/healthkit/hksample?language=objc] and you should be able to access it via {{const sample = HKQuantitySample.cast(sampleObj.objectAtIndex(0))}}. This may vary depending on the sample type you queried. You can use a simple for-loop to iterate over all objects in the {{sampleObj}} array.\r\n\r\nPlease read the docs more carefully. All your errors have been because of spelling errors or the use of wrong types. If you require further assistance please resort to the community slack as this is getting way of scope of this ticket.\r\n", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-08T18:25:49.000+0000", "updated": "2018-11-08T18:25:49.000+0000" }, { "id": "443435", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Dear Jan,\r\nits maybe more a problem that casting of objects isn't described very well. just 4 or 5 lines of text. \r\n\r\nIf I get you right. I have an object of type HKQuantitySample in my variable. Means an object with different properties. One property is, regarding to apple, HKQuantity defined in 'Healthkit/HKQuantity', which I define like this: var HKQuantity = require('HealthKit/HKQuantity'); I do the same when creating the object for writing. \r\n\r\nSo I should be able to access the property value with var wq = sample.HKQuantity?\r\nunfortunately the result is null instead of 80", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T19:56:43.000+0000", "updated": "2018-11-08T19:56:43.000+0000" }, { "id": "443439", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Just for your info!\r\nit is very interesting, that its not a single cast object hyperloop gives back\r\n\r\n var HKQuantitySample = require('HealthKit/HKQuantitySample');\r\n var HKObject = require('HealthKit/HKObject');\r\n var sample = HKObject.cast(sampleObj.objectAtIndex(0));\r\n var sample1 = HKQuantitySample.cast(sampleObj.objectAtIndex(0));\r\n epr.fct.iDebug(sample.UUID); //gives a result\r\n epr.fct.iDebug(sample.MetaData); //gives null\r\n epr.fct.iDebug(sample.Device); //gives null\r\n epr.fct.iDebug(sample1.enddate); //gives null\r\n epr.fct.iDebug(sample1.startdate); //gives null\r\n epr.fct.iDebug(sample1.quantity); // gives a result 80 kg as stored\r\n\r\nYou cannot found those info in the documentation. its just try and error\r\n ", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T22:03:47.000+0000", "updated": "2018-11-08T22:03:47.000+0000" }, { "id": "443443", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "got now everything without startDate and endDate. Any Idea?", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T22:43:22.000+0000", "updated": "2018-11-08T22:43:22.000+0000" }, { "id": "443444", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Try start{color:red}D{color}ate and end{color:red}D{color}ate, with a capital D, see here: https://developer.apple.com/documentation/healthkit/hksample/1615481-startdate?language=objc", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-11-08T22:48:41.000+0000", "updated": "2018-11-08T22:48:41.000+0000" }, { "id": "443446", "author": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I did as well. no chance. no success", "updateAuthor": { "name": "mollin", "key": "mollin", "displayName": "Joachim Mollin", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-08T23:11:40.000+0000", "updated": "2018-11-08T23:11:40.000+0000" } ], "maxResults": 39, "total": 39, "startAt": 0 } } }