Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-23751

Hyperloop iOS: Block callback arguments are null

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 5.4.0
    • Fix Version/s: Release 5.5.0, hyperloop 1.2.7
    • Component/s: Hyperloop, iOS
    • Labels:
    • Environment:

      Appc CLI NPM: 4.2.7
      Appc CLI Core: 5.4.0-40
      Arrow: 1.8.2
      SDK: 5.4.0.v20160804185318
      Node: v4.4.7
      OS: Mac OS X (10.11.6)
      Xcode: 7.3.1
      Device: iphone 6 plus (9.3.4)

    • Story Points:
      5

      Description

      Details: If you call LAContext.evaluatePolicyLocalizedReasonReply, null is returned for the success parameter instead of true or false.

      Steps to reproduce:

      1. Create a classic app: appc new --classic
      2. In the Resources folder, add/replace the following code:
        app.js

        /**
         * Appcelerator Titanium Mobile
         * Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved.
         * Licensed under the terms of the Apache Public License
         * Please see the LICENSE included with this distribution for details.
         *
         */
         
        // WARNING!
        //
        // THIS MODULE WILL ONLY RUN ON AN IOS 8 DEVICE
        //
         
        var TiTouchId = require('ti.touchid');
         
        var win = Ti.UI.createWindow();
         
        var btn = Ti.UI.createButton({
        	title: 'authenticate'
        });
         
        win.add(btn);
        win.open();
         
        btn.addEventListener('click', function(){
         
        	if(!TiTouchId.isSupported()) {
        		alert("Touch ID is not supported on this device!");
        		return;
        	}
         
        	TiTouchId.authenticate({
        		reason: '#### We need your fingerprint to continue.',
        		callback: function(e) {
        			if (!e.success) {
        				console.log("Success? - " + e.success);
                        console.log("Error? - " + e.error);
                        console.log("Code? - " + e.code);
        			}
                    else {
        			  	// do something useful
        				alert('YAY! success');
        			}
        		}
        	});
         
        });
        

        ti.touchid.js

        /**
         * Ti.TouchID
         *
         * Summary:	Support native Touch ID with Hyperloop in Titanium Mobile.
         * Author: 	Hans Knoechel | Appcelerator, Inc
         * Date: 	03/22/2016
         * Version:	0.1.0
         * Example
         *
         *	var touchID = require("ti.touchid");
         *	if (touchID.isSupported()) {
         *		touchID.authenticate({
         *			reason : "Please verify to reset all devices",
         *			callback : function(e) {
         * 				Ti.API.warn("Success? - " + e.success);
         *				Ti.API.warn("Error? - " + e.error);
         *				Ti.API.warn("Code? - " + e.code);
         *			}
         *		});
         *	}
         */
         
        var UIDevice = require("UIKit/UIDevice");
        var NSNumericSearch = require("Foundation").NSNumericSearch;
        var NSOrderedAscending = require("Foundation").NSOrderedAscending;
        var LAContext = require('LocalAuthentication/LAContext');
        var LocalAuthentication = require('LocalAuthentication/LocalAuthentication');
        var context = new LAContext();
         
        function isSupported() {
        	var currentOSSupported = UIDevice.currentDevice().systemVersion.compareOptions("8.0", NSNumericSearch) != NSOrderedAscending;
        	var touchIDSupported = context.canEvaluatePolicyError(LocalAuthentication.LAPolicyDeviceOwnerAuthenticationWithBiometrics);
         
        	return currentOSSupported && touchIDSupported;
        }
         
        function authenticate(args) {
        	var reason = args.reason || null;
        	var callback = args.callback || null;
         
        	if (!reason || !callback) {
        		Ti.API.error("Ti.TouchID: Please provide a valid 'reason' and 'callback' parameter.");
        		return;
        	}
         
        	context.evaluatePolicyLocalizedReasonReply(LocalAuthentication.LAPolicyDeviceOwnerAuthenticationWithBiometrics, reason, function(success, error) {
        		var attrs = {
        			success : success
        		};
         
        		if (error) {
        			attrs["error"] = error.localizedDescription;
        			attrs["code"] = error.code;
        		}
         
        		callback(attrs);
        	});
        }
         
        exports.isSupported = isSupported;
        exports.authenticate = authenticate;
        

      3. Install the app to an iOS device that is touch id supported; make sure the touch id is enabled first before installing
      4. Launch the app and press on the authenticate button
      5. Use your fingerprint to continue

      Actual: In the console, success is null:

      [INFO]  Success? - null
      [INFO]  Error? - undefined
      [INFO]  Code? - undefined
      

      Expected: Success should either be true or false with the appropriate error message and error code.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jvennemann Jan Vennemann
                Reporter:
                wluu Wilson Luu (Inactive)
                Reviewer:
                Hans Knöchel
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-10000
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration