Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23902] Hyperloop: iOS - Numeric attribute in blocks not returned correctly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2017-04-04T14:39:42.000+0000
Affected Version/sn/a
Fix Version/sHyperloop 2.1.0
ComponentsHyperloop, iOS, Tooling
Labelsn/a
ReporterHans Knöchel
AssigneeJan Vennemann
Created2016-09-14T15:32:21.000+0000
Updated2017-04-17T22:20:33.000+0000

Description

Numeric values that are returned in block-attributes are returned to the application incorrectly. *Use-case*: Copy the following in the plist-section of your tiapp.xml:
<key>NSSpeechRecognitionUsageDescription</key>
<string>Can we parse your spoken words?</string>
Run the following code on an iOS 10 device with a new appc-project (appc new -p ios):
var SFSpeechRecognizer = require("Speech/SFSpeechRecognizer");
var SFSpeechRecognizerAuthorizationStatusAuthorized = require("Speech").SFSpeechRecognizerAuthorizationStatusAuthorized;
    
var win = Ti.UI.createWindow({
    backgroundColor: "#fff"
});

var btn = Ti.UI.createButton({
    title: "Request authorization"
});

btn.addEventListener("click", function() {
    SFSpeechRecognizer.requestAuthorization(function(status) {
        alert(status) // The "status" returns "{}" instead of "3" (int-value of the constant)

        // This will return "false", since the status ({}) is not equal the constant (3)
        // alert("Authorized: " + status == SFSpeechRecognizerAuthorizationStatusAuthorized);
    });
});

win.add(btn);
win.open();
Expected behavior: An alert "3" is shown Actual behavior: An alert "{}" is shown

Comments

  1. Jan Vennemann 2016-10-10

    No, this one is caused by a wrong handling of enums in the block callback wrapper. I will look into it and see how we can properly detect the type of the enum and then do the required conversions.
  2. Jan Vennemann 2017-04-04

    PR (master): https://github.com/appcelerator/hyperloop.next/pull/139 PR (2_0_X): https://github.com/appcelerator/hyperloop.next/pull/140
  3. Abir Mukherjee 2017-04-17

    Verified fix with this environment: Node Version: 6.10.1 NPM Version: 3.10.10 Mac OS: 10.12.4 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.9 Appcelerator Studio, build: 4.8.1.201612050850 Xcode 8.2.1 Hyperloop 2.1.0 (master) and 2.0.1 iOS 10.2 I tested the above demo code on an iOS 10.2 Device and found that it worked as expected. Specifically, I confirmed that "3" was shown in the Alert box after pressing the button.

JSON Source