Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19376] Android: Fingerprint support

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-07-27T18:55:50.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsAndroid
Labelsparity, touchid
ReporterChee Kiat Ng
AssigneeAshraf Abu
Created2015-08-19T04:53:08.000+0000
Updated2017-01-04T10:53:22.000+0000

Description

Android M supports fingerprint authentication. Refer to http://developer.android.com/preview/api-overview.html and https://github.com/googlesamples/android-FingerprintDialog Try to achieve parity and package with ti.touchid module.

Attachments

FileDateSize
2016_07_08_15_38_38.mp42016-07-08T22:47:30.000+00003079567
Screenshot_20160727-155415.png2016-07-27T07:59:09.000+000098219

Comments

  1. Talal M 2016-01-18

    Did any body find a solution for Android touchid fingerprint authentication using ti.touchid or any other module built for Appcelerator Titanium ?
  2. saamy 2016-02-18

    I'm looking for Android TouchID module as well. Any Update from Appcelerator ? or anyone created module already ?
  3. sponnusamy 2016-04-08

    When we can expect this module ?
  4. Chee Kiat Ng 2016-04-11

    We are working on it. See Fix Release version. Do also note that the only devices that support this is Nexus 5x and 6p.
  5. Hans Knöchel 2016-05-06

    PR: https://github.com/appcelerator-modules/ti.touchid/pull/18
  6. Ashraf Abu 2016-05-17

    PR reviewed and merged.
  7. Hans Knöchel 2016-05-24

    PR (titanium_mobile/master): https://github.com/appcelerator/titanium_mobile/pull/8017
  8. Hans Knöchel 2016-05-25

    [~titanium@webmasterei-hamburg.de] tested the module in master and had some trouble we might want to address: {quote} 1. He needed to rebuild, because a jar was missing 2. He needed to set the permissions <uses-permission android:name="android.permission.USE_FINGERPRINT"/> manually (can we put it into timodule.xml?? At least we should leave a comment about it in the example) 3. The module must be required after opening a window/activity 4. TiTouchId.isSupported() always returns true? (5. We should start to create a README.md for that project to note those infos) {quote}
  9. Rainer Schleevoigt 2016-05-25

    For usage with old API levels we need a method like getAuthorisationOrTrueIfOldVersion() for usage the same async structur. These helper functions has different output, maybe it is a good idea to make in same style: [INFO] : isSupported()=true [INFO] : {"canAuthenticate":true}
  10. Hieu Pham 2016-05-25

    Thanks [~hansknoechel], I'll look into these issues.
  11. Hieu Pham 2016-05-25

    1. Which jar is missing? 2. The permission should already be in timodule.xml: https://github.com/appcelerator-modules/ti.touchid/blob/master/android/timodule.xml#L11 3. What do you mean? It doesn't work if you do require("touch.id") before you open a window? That doesn't sound right. 4. This will return false on devices that doesn't have fingerprint support. There are currently only Nexus 5x and 6p that support this feature.
  12. Rainer Schleevoigt 2016-05-26

    1. Hans sent me azip of module. After including and usage came an error "jat not found" and I have recomplied => without error at runtime 2. you are right, I forgot to copy 3. I have embed the module at "construction time" of window and a weird error message came. Then I have embed the code after open event of activity and the error disappeared. 4. if the module should run in all devices and the critical action is inside the async node, then it is a good idea to offer a dummy method. In other case the coder must implement a logic to realize this. (similar this wrapper: https://gist.github.com/AppWerft/6ba7b7ba8d14a269bb05f1b319d754f4)
  13. Hieu Pham 2016-05-26

    [~titanium@webmasterei-hamburg.de], which error did you see on 3?
  14. Lokesh Choudhary 2016-07-08

    I see the following issues running the example app from the module: 1. I click on Authenticate & place my correct finger on the fingerprint reader. 2. I get alert YAY! success. 3. I click on authenticate again & place the incorrect finger on the fingerprint reader. 4. I get alert Message:Unable to recognize fingerprint. 5. I click Authenticate again. 6. I get alert Message: Fingerprint operation cancelled. I get this as long as I keep scanning my wrong finger. 7. If I place my correct finger on the fingerprint scanner it scans & I get a success. Attached a video for this issue: [^2016_07_08_15_38_38.mp4] Reopening as of now. Environment: Appc Studio : 4.7.0.201607070843 Ti SDK : 5.4.0.v20160705213725 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.5 Appc NPM : 4.2.8-1 Appc CLI : 5.4.0-28 Node: 4.4.4 Nexus5X: Android 6.0.1
  15. Ashraf Abu 2016-07-11

    [~lchoudhary] I assume the expected behaviour for number 6 would be the same results as number 4?
  16. Lokesh Choudhary 2016-07-11

    [~msamah], 1. Everything works fine until step 4. 2. At step 5 I again click authenticate & I after clicking authenticate I get alert Message: Fingerprint operation cancelled. 3. I keep on getting this Message: Fingerprint operation cancelled until I scan my correct finger. So basically, after a failure it will keep showing you alert Message: Fingerprint operation cancelled every time I click authenticate, until you scan the correct finger (FYI, at this step even though you get an alert Message: Fingerprint operation cancelled the scanner can still scan the finger.)
  17. Ashraf Abu 2016-07-27

    [~lchoudhary] This is actually expected behaviour. What's happening is that at step 4, once you get an Unable to recognize fingerprint, you should not press authenticate again. Instead, you should just provide another fingerprint for the sensor to read. Ideally it should instead show a blocking dialog UI for the fingerprint. Be it success or failure. This is because it is waiting till you provide a correct fingerprint and will stay there even at failure. (You might have a dirty finger after all and need to clean it. Thus it lets you read it again). !Screenshot_20160727-155415.png|thumbnail! I would suggest that we resolve this ticket (and perhaps document this) as it is and create a ticket for a improvement on this flow. [~lchoudhary] Reference https://github.com/googlesamples/android-FingerprintDialog
  18. Ashraf Abu 2016-07-27

    [~lchoudhary] If my idea is acceptable please resolve this issue.
  19. Hans Knöchel 2016-07-27

    [~msamah] Can we make a tiny doc-note for that? Guess it's fine then.
  20. Ashraf Abu 2016-07-27

    Ya. I'll proceed with a doc.
  21. Ashraf Abu 2016-07-27

    Doc PR: https://github.com/appcelerator-modules/ti.touchid/pull/21 [~hansknoechel] For your review.
  22. Hans Knöchel 2016-07-27

    Merged. Please also consider to update the pre-packaged, although it's only a docs update.
  23. Lokesh Choudhary 2016-07-27

    The behaviour seems to be as expected. Verified the addition of doc note. Closing. Environment: Appc Studio : 4.7.0.201607111053 Ti SDK : 5.4.0.v20160725003348 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.5 Appc NPM : 4.2.8-1 Appc CLI : 5.4.0-34 Node: 4.4.4 Nexus 5X - Android 6.0.1
  24. Lokesh Choudhary 2016-07-27

    Reopening to correct comment
  25. Ashraf Abu 2016-07-28

    Created ticket MOD-2278 for the improvement mentioned here.
  26. Ashraf Abu 2016-07-28

    For document update: Updated module PR: https://github.com/appcelerator-modules/ti.touchid/pull/22 Added to release: https://github.com/appcelerator-modules/ti.touchid/releases/tag/android-2.0.1 Ti SDK PR: https://github.com/appcelerator/titanium_mobile/pull/8166
  27. Ashraf Abu 2016-07-28

    PRs merged.
  28. Rainer Schleevoigt 2017-01-02

    Using of version 2.0.1 (compiled with SDK6.0.0) doesn't show any UI. testes devices: Galaxy6Edge with M and ZTEBlade7 with M.
  29. Hans Knöchel 2017-01-02

    [~titanium@webmasterei-hamburg.de] See the mentioned ticket (MOD-2278) for this, we discussed it earlier. The current Touch ID implementation on Android does not seem to have a UI expected. Feel free to add this functionality on Android as well.
  30. Hans Knöchel 2017-01-02

    Addition: And it is not natively supported. All that the [Google sample](https://github.com/googlesamples/android-FingerprintDialog) does is to create a custom UI to mock this behavior. Developers usually create their own UI on Android, see [this](http://blog.m2sys.com/wp-content/uploads/2015/11/Android-fingerprint.jpg) and [this](http://cdn.bgr.com/2015/05/dashlane-android-m-fingerprint-support.jpg?quality=98&strip=all) example as well.
  31. Rainer Schleevoigt 2017-01-03

    In this case a modified example/app.js is meaningful. This irritates me: after start of authenticate comes immediately the error message ("Cancel by user"). I could create a dialog with text/image, but how handle, if the function doesn't wait.
  32. Rainer Schleevoigt 2017-01-03

    This works for me:
    javascript
        module.exports = function(options, callbacks) {
        	var start = new Date().getTime();
        	if (!TouchId.isSupported()) {
        		alert("This device doesn't support fingerprint sensor");
        		return;
        	}
        	var dialog = null;
        	if (Ti.Platform.osname == "android") {
        		var timer = 0;
        		var cronHandler = function() {
        			timer++;
        			if (timer == 600) {
        				clearInterval(cron);
        			} else {
        				androidView.children[0].backgroundImage = "/assets/fingerprint"
        						+ timer % 9 + '.png';
        				progress.setValue(timer);
        			}
        		};
        		var cron = setInterval(cronHandler, 100);
        		var androidView = Ti.UI.createView({
        			top : 10,
        			bottom : 10
        		});
        		androidView.add(Ti.UI.createView({
        			top : 10,
        			left : 10,
        			width : 80,
        			height : 90,
        			backgroundImage : "/assets/fingerprint.png"
        		}));
        		androidView.add(Ti.UI.createLabel({
        			left : 100,
        			right : 10,
        			top : 5,
        			text : options.message
        		}));
        		var progress = Ti.UI.createProgressBar({
        			width : Ti.UI.FILL,
        			top : 100,
        			left : 10,
        			right : 10,
        			min : 0,
        			max : 600
        		});
        		androidView.add(progress);
        		progress.show();
        		dialog = Ti.UI.createOptionDialog({
        			title : options.title,
        			androidView : androidView,
        			buttonNames : [ "Abbruch" ]
        		});
        		dialog.addEventListener("click",function(e){
        			console.log(e.index);
        		})
        		dialog.show();
        	}
        	TouchId
        			.authenticate({
        				reason : 'We need your fingerprint to continue.',
        				callback : function(e) {
        					if (!!dialog)
        						dialog.hide();
        					console.log("Code=" + e.code);
        					if (!e.success) {
        						var end = new Date().getTime();
        						console.log("TIMEOUT=" + parseInt(end - start));
        						Ti.Media.vibrate([ 0, 30 ]);
        						Ti.UI
        								.createNotification(
        										{
        											message : "Zugang zur Belegübersicht ohne Fingersensorschutz"
        										}).show();
        
        					} else {
        						callbacks.onsuccess();
        					}
        				}
        			});
        
        };
        
  33. Rainer Schleevoigt 2017-01-03

    This are possible payloads from callback: {"message":"GurgsDNfmFvbkiR6IK0atg==\n","success":true} {"error":"Unable to recognize fingerprint","success":false} {"error":"Fingerprint operation canceled.","success":false} Maybe we need an integer result code to better analyze the result. In FingerPrintHelper.java#115 we need an additional property "code" and in 124, 131,140 modifications. next time I will send a PR.
  34. Rainer Schleevoigt 2017-01-04

    I have a PR done. It adds resultcodes to every callback (for i18n) and exposed the helpers/hints like "Make sure that your finger covers the entire Home key" or "Keep your finger on the Home key a little longer" with resultcode. A list of new constants is added.
  35. Rainer Schleevoigt 2017-01-04

    For UI look to this [gist](https://gist.github.com/AppWerft/53469996b2a0589a037d2622fea6eb65) !https://github.com/AppWerft/ti.touchid/blob/master/android/assets/fingerprintDialog_screenshot.png!

JSON Source