Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6008] error while writing data to Apple HealthKit

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2019-01-16T11:31:42.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsHyperloop, Titanium SDK & CLI
Labelsn/a
ReporterJoachim Mollin
AssigneeShak Hossain
Created2018-11-05T10:11:39.000+0000
Updated2019-01-16T11:31:42.000+0000

Description

Hi, I better open a new Issue, as I saw that the former issue was closed. I can write Samples to Apple HealthKit but have problems to read them back. Everything ist accepted until I want to execute the query. Hope you can help. I tried building the query with 3 different methods (see in code): Version 1 -> App starts but closed immediately. No error occurred Version 3 -> the same. All debugs were shown For version 2 I got: -[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40 [ERROR] : Script Error { [ERROR] : column = 26; [ERROR] : description = "-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40"; [ERROR] : line = 133; [ERROR] : message = "-[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x600000d6bd40"; [ERROR] : name = NSInvalidArgumentException; [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"; [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"; [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)"; [ERROR] : } Code: //sampleType = HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryEnergyConsumed) var HKSampleType = require('HealthKit/HKSampleType'); var sampleType = HKSampleType.quantityTypeForIdentifier(require('HealthKit').HKQuantityTypeIdentifierBodyMass); epr.fct.iDebug(HKSampleType); epr.fct.iDebug(sampleType); epr.fct.iDebug("END SAMPLETYPE"); //let predicate = HKQuery.predicateForSamplesWithStartDate(startDate, endDate: endDate, options: .None) var HKQuery = require('HealthKit/HKQuery'); var predicate = HKQuery.predicateForSamplesWithStartDateEndDateOptions(startDate, endDate, null); epr.fct.iDebug(predicate); epr.fct.iDebug("END PREDICAT"); //Sort //NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO]; var HKSort = require('Foundation/NSSortDescriptor'); var sortDesc = new HKSort(require('HealthKit').HKSampleSortIdentifierEndDate,true); epr.fct.iDebug(sortDesc); epr.fct.iDebug("END SORT"); //init(sampleType: HKSampleType,predicate: NSPredicate?,limit: Int,sortDescriptors: [NSSortDescriptor]?,resultsHandler: @escaping (HKSampleQuery, [HKSample]?, Error?) -> Void) var HKSampleQuery = require('HealthKit/HKSampleQuery'); epr.fct.iDebug(HKSampleQuery); //version 1 var query = HKSampleQuery.alloc().init(sampleType, predicate, require('HealthKit').HKObjectQueryNoLimit, sortDesc, fctResult); //version 2 //var query = new HKSampleQuery(sampleType, predicate, require('HealthKit').HKObjectQueryNoLimit, sortDesc, fctResult); //version 3 /*q = new HKSampleQuery(); q.sampleType = sampleType; q.predicate = predicate; q.limit = require('HealthKit').HKObjectQueryNoLimit; q.sortDescriptors = sortDesc; q.resultsHandler = fctResult; epr.fct.iDebug(q); query = q;*/ epr.fct.iDebug(query); epr.fct.iDebug("END query"); var ok = epr.hk.healthStore.executeQuery(query); epr.fct.iDebug("END EXECUTE");

Comments

  1. Joachim Mollin 2018-11-05

    This error is shown in the Simulator /hkhealthstore.js:133 var result = $dispatch(this.$native, 'executeQuery:', [_query], true); ^ -[HKQuantityType activateWithClientQueue:healthStore:delegate:completion:]: unrecognized selector sent to instance 0x6000031760d0 at dispatch@[native code] 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) 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) 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) 4 mcx alexa 0x000000010c9b13ec -[KrollInvocation invoke:] + 124 5 mcx alexa 0x000000010c9b2a53 -[KrollContext invoke:] + 163 6 mcx alexa 0x000000010c9b2e19 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 169 7 mcx alexa 0x000000010c9ab614 -[KrollBridge evalFile:callback:selector:] + 116 8 mcx alexa 0x000000010c9ac4a8 -[KrollBridge didStartNewContext:] + 2600 9 mcx alexa 0x000000010c9b370a -[KrollContext main] + 1834 10 mcx alexa 0x000000010c9b2827 __21-[KrollContext start]_block_invoke + 39 11 libdispatch.dylib 0x000000011509e4e1 _dispatch_call_block_and_release + 12 12 libdispatch.dylib 0x000000011509f54b _dispatch_client_callout + 8 13 libdispatch.dylib 0x00000001150ab380 _dispatch_main_queue_callback_4CF + 1290 14 CoreFoundation 0x0000000113aef3e9 _CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE_ + 9 15 CoreFoundation 0x0000000113ae9a76 __CFRunLoopRun + 2342 16 CoreFoundation 0x0000000113ae8e11 CFRunLoopRunSpecific + 625 17 GraphicsServices0x0000000118ee31dd GSEventRunModal + 62 18 UIKitCore 0x000000011f43d81d UIApplicationMain + 140 19 mcx alexa 0x000000010c997b86 main + 102
  2. Sharif AbuDarda 2018-11-29

    Hello, Please provide a standalone sample code that can be used to reproduce the issue. Thanks.
  3. Rakhi Mitro 2018-12-10

    Hello, Just passing as update here.Are you able to get that sorted out?  Please let us know if you need more help with this issue.
  4. Rakhi Mitro 2019-01-02

    Hello, We have not heard back from you since our last update.I just wanted to follow up with you about this issue? Are you still experiencing this problem? Please let us know if you need more help with this issue. Thanks

JSON Source