赞
踩
Android平台6.0及以上系统支持,仅适配Google官方指纹识别的标准接口的设备。
5+功能模块(permissions)
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#ffffff">{</span>
- <span style="color:#87ceeb">// ...</span>
- <span style="color:#ffa0a0">"permissions"</span><span style="color:#ffffff">:{</span>
- <span style="color:#87ceeb">// ...</span>
- <span style="color:#ffa0a0">"Fingerprint"</span><span style="color:#ffffff">:</span> <span style="color:#ffffff">{</span>
- <span style="color:#ffa0a0">"description"</span><span style="color:#ffffff">:</span> <span style="color:#ffa0a0">"指纹识别"</span>
- <span style="color:#ffffff">}</span>
- <span style="color:#ffffff">}</span>
- <span style="color:#ffffff">}</span>
- </code></span></span>
当前设备环境是否支持指纹识别
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>boolean</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isSupport</span><span style="color:#ffffff">();</span>
- </code></span></span>
目前还有很多设备没有指纹识别模块,需要调用此方法判断是否可使用指纹识别功能。
无
Boolean : 设备支持指纹识别则返回true,否则返回false。
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 判断设备是否支持指纹识别</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getElementById</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'result'</span><span style="color:#ffffff">).</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isSupport</span><span style="color:#ffffff">()?</span><span style="color:#ffa0a0">'支持'</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'不支持'</span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#f0e68c"><strong>else</strong></span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> console</span><span style="color:#ffffff">.</span><span style="color:#ffffff">log</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">"请更新版本"</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 当前设备环境是否支持指纹识别: </span><span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><p</strong></span> <span style="color:#bdb76b"><strong>id</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"result"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">...</span><span style="color:#f0e68c"><strong></p></strong></span> <span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
当前设备是否设置密码锁屏
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>boolean</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isKeyguardSecure</span><span style="color:#ffffff">();</span>
- </code></span></span>
如果设备没有设置密码锁屏,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 调用plus.fingerprint.authenticate会返回失败。
无
Boolean : 设备已设置密码锁屏则返回true,否则返回false。
要求设置密码锁屏才可以使用指纹识别,如果没有设置密码锁屏应该提示用户进行设置。
不支持此功能,返回true。
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 判断设备是否设置密码锁屏</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getElementById</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'result'</span><span style="color:#ffffff">).</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isKeyguardSecure</span><span style="color:#ffffff">()?</span><span style="color:#ffa0a0">'是'</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'否'</span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#f0e68c"><strong>else</strong></span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> console</span><span style="color:#ffffff">.</span><span style="color:#ffffff">log</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">"请更新版本"</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 当前设备是否设置密码锁屏: </span><span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><p</strong></span> <span style="color:#bdb76b"><strong>id</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"result"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">...</span><span style="color:#f0e68c"><strong></p></strong></span> <span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
当前设备是否已经录入指纹
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>boolean</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isEnrolledFingerprints</span><span style="color:#ffffff">();</span>
- </code></span></span>
如果设备没有录入指纹,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 调用plus.fingerprint.authenticate会返回失败。
无
Boolean : 设备已经录入指纹则返回true,否则返回false。
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 判断设备是否已经录入指纹</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getElementById</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'result'</span><span style="color:#ffffff">).</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isEnrolledFingerprints</span><span style="color:#ffffff">()?</span><span style="color:#ffa0a0">'是'</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'否'</span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#f0e68c"><strong>else</strong></span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> console</span><span style="color:#ffffff">.</span><span style="color:#ffffff">log</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">"请更新版本"</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 当前设备是否已经录入指纹: </span><span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><p</strong></span> <span style="color:#bdb76b"><strong>id</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"result"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">...</span><span style="color:#f0e68c"><strong></p></strong></span> <span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
指纹识别认证
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#ffffff">successCB</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> errorCB</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> options</span><span style="color:#ffffff">);</span>
- </code></span></span>
用户可以开始输入指纹进行识别,如果认证成功则触发successCB回调,识别失败则触发errorCB回调返回错误信息。
指纹识别操作认证成功时调用。
指纹识别操作认证失败时调用,每次指纹识别错误都会触发一次错误回调。
用于设置指纹识别界面显示的提示信息等。
void : 无
指纹识别过程中不会弹出任何界面,需要开发者根据业务需求弹出提示信息。
指纹识别过程中会弹出系统界面。
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#f0e68c"><strong>var</strong></span><span style="color:#ffffff"> result </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getElementById</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'result'</span><span style="color:#ffffff">);</span> <span style="color:#87ceeb">// 检查是否支持指纹识别</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(!</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isSupport</span><span style="color:#ffffff">())</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> result</span><span style="color:#ffffff">.</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span> <span style="color:#ffa0a0">'此设备不支持指纹识别'</span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>return</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(!</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isKeyguardSecure</span><span style="color:#ffffff">())</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> result</span><span style="color:#ffffff">.</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span> <span style="color:#ffa0a0">'此设备未设置密码锁屏,无法使用指纹识别'</span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>return</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(!</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">isEnrolledFingerprints</span><span style="color:#ffffff">())</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> result</span><span style="color:#ffffff">.</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span> <span style="color:#ffa0a0">'此设备未录入指纹,请到设置中开启'</span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>return</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> result</span><span style="color:#ffffff">.</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span> <span style="color:#ffa0a0">'此设备支持指纹识别'</span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#f0e68c"><strong>else</strong></span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> result</span><span style="color:#ffffff">.</span><span style="color:#ffffff">innerText </span><span style="color:#ffffff">=</span> <span style="color:#ffa0a0">'当前环境不支持指纹识别API,请更新到最新版本'</span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#87ceeb">// 指纹识别认证 </span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> fingerpring</span><span style="color:#ffffff">()</span> <span style="color:#ffffff">{</span> <span style="color:#f0e68c"><strong>var</strong></span><span style="color:#ffffff"> waiting </span><span style="color:#ffffff">=</span> <span style="color:#f0e68c"><strong>null</strong></span><span style="color:#ffffff">;</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">closeWaiting</span><span style="color:#ffffff">();</span><span style="color:#87ceeb">//兼容Android平台关闭等待框</span><span style="color:#ffffff"> alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别成功'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">){</span> <span style="color:#f0e68c"><strong>switch</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span> <span style="color:#f0e68c"><strong>case</strong></span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">AUTHENTICATE_MISMATCH</span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">toast</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹匹配失败,请重新输入'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>case</strong></span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">AUTHENTICATE_OVERLIMIT</span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">closeWaiting</span><span style="color:#ffffff">();</span><span style="color:#87ceeb">//兼容Android平台关闭等待框</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败次数超出限制,请使用其它方式进行认证'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>default</strong></span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">closeWaiting</span><span style="color:#ffffff">();</span><span style="color:#87ceeb">//兼容Android平台关闭等待框</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败('</span><span style="color:#ffffff">+</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">+</span><span style="color:#ffa0a0">'),请重试'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">});</span> <span style="color:#87ceeb">// Android平台弹出等待提示框 </span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'Android'</span><span style="color:#ffffff">==</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">os</span><span style="color:#ffffff">.</span><span style="color:#ffffff">name</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">showWaiting</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别中...'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 指纹识别认证: </span><span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><p</strong></span> <span style="color:#bdb76b"><strong>id</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"result"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">...</span><span style="color:#f0e68c"><strong></p></strong></span> <span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><button</strong></span> <span style="color:#bdb76b"><strong>onclick</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"</span><span style="color:#ffffff">fingerpring</span><span style="color:#ffffff">()</span><span style="color:#ffa0a0">"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">指纹识别</span><span style="color:#f0e68c"><strong></button></strong></span> <span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
取消指纹识别认证
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">cancel</span><span style="color:#ffffff">();</span>
- </code></span></span>
取消当前正在处理的指纹识别认证操作。 如果当前没有进行指纹识别则不进行任何操作;如果当前正在进行指纹识别则触发错误回调(错误码为“CANCEL”)。
无
void : 无
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 自动调用指纹识别</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">toast</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别成功'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">){</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败('</span><span style="color:#ffffff">+</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">+</span><span style="color:#ffa0a0">')'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">});</span> <span style="color:#87ceeb">// iOS平台指纹识别提示框会阻塞界面操作,定时调用</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'iOS'</span><span style="color:#ffffff">==</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">os</span><span style="color:#ffffff">.</span><span style="color:#ffffff">name</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> setTimeout</span><span style="color:#ffffff">(</span><span style="color:#ffffff">cancelFingerpring</span><span style="color:#ffffff">,</span> <span style="color:#cd5c5c">10000</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#87ceeb">// 取消指纹识别</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> cancelFingerpring</span><span style="color:#ffffff">()</span> <span style="color:#ffffff">{</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">cancel</span><span style="color:#ffffff">();</span> <span style="color:#ffffff">}</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 取消指纹识别认证 </span><span style="color:#f0e68c"><strong><br/></strong></span> <span style="color:#f0e68c"><strong><button</strong></span> <span style="color:#bdb76b"><strong>onclick</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"</span><span style="color:#ffffff">cancelFingerpring</span><span style="color:#ffffff">()</span><span style="color:#ffa0a0">"</span><span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff">取消识别</span><span style="color:#f0e68c"><strong></button></strong></span> <span style="color:#f0e68c"><strong><br/></strong></span><span style="color:#ffffff"> 注意:iOS平台10秒后自动取消 </span><span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
JSON对象,指纹识别认证参数
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>interface</strong></span> <span style="color:#98fb98">AuthenticateOptions</span> <span style="color:#ffffff">{</span>
- <span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#98fb98">String</span><span style="color:#ffffff"> message</span><span style="color:#ffffff">;</span>
- <span style="color:#ffffff">}</span>
- </code></span></span>
用于设置指纹识别认证界面显示的提示信息等。
如果指纹识别认证过程中不显示提示框,则不显示此信息。
指纹识别认证过程中不显示提示框,需要开发者自定义显示。
指纹识别认证过程中显示系统提示框,在提示框中显示此信息(默认显示信息为空字符串)。
<span style="background-color:#333333"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#f0e68c"><strong>var</strong></span><span style="color:#ffffff"> waiting </span><span style="color:#ffffff">=</span> <span style="color:#f0e68c"><strong>null</strong></span><span style="color:#ffffff">;</span> <span style="color:#87ceeb">// 自动调用指纹识别</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> waiting</span><span style="color:#ffffff">&&(</span><span style="color:#ffffff">waiting</span><span style="color:#ffffff">.</span><span style="color:#ffffff">onclose</span><span style="color:#ffffff">=</span><span style="color:#f0e68c"><strong>null</strong></span><span style="color:#ffffff">);</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">closeWaiting</span><span style="color:#ffffff">();</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别成功'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">){</span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">AUTHENTICATE_MISMATCH </span><span style="color:#ffffff">==</span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">){</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">toast</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹匹配失败,请重新输入'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>return</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> waiting</span><span style="color:#ffffff">&&(</span><span style="color:#ffffff">waiting</span><span style="color:#ffffff">.</span><span style="color:#ffffff">onclose</span><span style="color:#ffffff">=</span><span style="color:#f0e68c"><strong>null</strong></span><span style="color:#ffffff">);</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">closeWaiting</span><span style="color:#ffffff">();</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败('</span><span style="color:#ffffff">+</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">+</span><span style="color:#ffa0a0">')'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},{</span><span style="color:#ffffff"> message</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'通过Home键验证已有手机指纹'</span> <span style="color:#ffffff">});</span> <span style="color:#87ceeb">// Android平台使用自定义等待框显示 </span> <span style="color:#f0e68c"><strong>if</strong></span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">"Android"</span><span style="color:#ffffff">==</span><span style="color:#ffffff">plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">os</span><span style="color:#ffffff">.</span><span style="color:#ffffff">name</span><span style="color:#ffffff">){</span><span style="color:#ffffff"> waiting </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">showWaiting</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'验证已有手机指纹'</span><span style="color:#ffffff">,{</span><span style="color:#ffffff">width</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'196px'</span><span style="color:#ffffff">,</span><span style="color:#ffffff">height</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'196px'</span><span style="color:#ffffff">,</span><span style="color:#ffffff">padding</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'16px'</span><span style="color:#ffffff">,</span><span style="color:#ffffff">loading</span><span style="color:#ffffff">:{</span><span style="color:#ffffff">height</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'96px'</span><span style="color:#ffffff">,</span><span style="color:#ffffff">icon</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'fp.png'</span><span style="color:#ffffff">},</span><span style="color:#ffffff">background</span><span style="color:#ffffff">:</span><span style="color:#ffa0a0">'rgba(0,0,0,0.3)'</span><span style="color:#ffffff">});</span><span style="color:#ffffff"> waiting</span><span style="color:#ffffff">.</span><span style="color:#ffffff">onclose </span><span style="color:#ffffff">=</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> waiting </span><span style="color:#ffffff">=</span> <span style="color:#f0e68c"><strong>null</strong></span><span style="color:#ffffff">;</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">cancel</span><span style="color:#ffffff">();</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 指纹识别认证 </span><span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span>
JSON对象,指纹识别错误信息
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>interface</strong></span> <span style="color:#98fb98">FingerprintError</span> <span style="color:#ffffff">{</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> UNSUPPORT </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">1</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> KEYGUARD_INSECURE </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">2</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> FINGERPRINT_UNENROLLED </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">3</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> AUTHENTICATE_MISMATCH </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">4</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> AUTHENTICATE_OVERLIMIT </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">5</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> CANCEL </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">6</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>const</strong></span> <span style="color:#98fb98">Number</span><span style="color:#ffffff"> UNKNOWN_ERROR </span><span style="color:#ffffff">=</span> <span style="color:#cd5c5c">7</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#98fb98">Number</span><span style="color:#ffffff"> code</span><span style="color:#ffffff">;</span>
- <span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#98fb98">String</span><span style="color:#ffffff"> message</span><span style="color:#ffffff">;</span>
- <span style="color:#ffffff">}</span>
- </code></span></span>
当前设备不支持指纹识别功能时返回此错误,错误代码常量值为1。
当前设备为设置密码锁屏导致无法使用指纹识别功能时返回此错误,错误代码常量值为2。
当前设备未录入指纹导致无法使用指纹识别功能时返回此错误,错误代码常量值为3。
用户指纹识别认证不通过时返回此错误,错误代码常量值为4。 用户每次尝试指纹识别认证未通过都会触发此错误,此时还可以继续识别认证。
用户多次指纹识别认证不通过时返回此错误,错误代码常量值为5。 通常出现此错误后系统会锁定一段时间禁止使用指纹识别,如果再次调用指纹识别认证会立即返回此错误,因此出现此错误时应该提示用户使用其它方式进行认证。
用户取消指纹识别认证时返回此错误,错误代码常量值为6。
其它未知错误,错误代码常量值为7。
取值范围为FingerprintError对象的错误常量值。
详细错误描述信息。
指纹识别认证成功回调函数
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> onSuccess</span><span style="color:#ffffff">()</span> <span style="color:#ffffff">{</span>
- <span style="color:#87ceeb">// Authenticate success code.</span>
- <span style="color:#ffffff">}</span>
- </code></span></span>
无
void : 无
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 自动调用指纹识别</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别成功'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">){</span><span style="color:#ffffff"> console</span><span style="color:#ffffff">.</span><span style="color:#ffffff">log</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败('</span><span style="color:#ffffff">+</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">+</span><span style="color:#ffa0a0">')'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">});</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 指纹识别认证 </span><span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span> </code></span></span>
指纹识别认证失败的回调函数
- <span style="background-color:#333333"><span style="color:#474747"><code>
- <span style="color:#f0e68c"><strong>function</strong></span> <span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> onError</span><span style="color:#ffffff">(</span><span style="color:#98fb98">FingerprintError</span><span style="color:#ffffff"> error</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span>
- <span style="color:#87ceeb">// Handle error</span>
- <span style="color:#f0e68c"><strong>var</strong></span><span style="color:#ffffff"> code </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> error</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">;</span> <span style="color:#87ceeb">// 错误编码</span>
- <span style="color:#f0e68c"><strong>var</strong></span><span style="color:#ffffff"> message </span><span style="color:#ffffff">=</span><span style="color:#ffffff"> error</span><span style="color:#ffffff">.</span><span style="color:#ffffff">message</span><span style="color:#ffffff">;</span> <span style="color:#87ceeb">// 错误描述信息</span>
- <span style="color:#ffffff">}</span>
- </code></span></span>
可通过error.code(Number类型)获取错误编码; 可通过error.message(String类型)获取错误描述信息。
void : 无
<span style="background-color:#333333"><span style="color:#474747"><code> <span style="color:#cccccc"><!DOCTYPE html></span> <span style="color:#f0e68c"><strong><html></strong></span> <span style="color:#f0e68c"><strong><head></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>name</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"viewport"</span> <span style="color:#bdb76b"><strong>content</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span><span style="color:#f0e68c"><strong>/></strong></span> <span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Fingerprint Example</span><span style="color:#f0e68c"><strong></title></strong></span> <span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span> <span style="color:#87ceeb">// H5 plus事件处理</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">(){</span> <span style="color:#87ceeb">// 自动调用指纹识别</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">fingerprint</span><span style="color:#ffffff">.</span><span style="color:#ffffff">authenticate</span><span style="color:#ffffff">(</span><span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(){</span><span style="color:#ffffff"> console</span><span style="color:#ffffff">.</span><span style="color:#ffffff">log</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别成功'</span><span style="color:#ffffff">);</span> <span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">){</span> <span style="color:#f0e68c"><strong>switch</strong></span><span style="color:#ffffff">(</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span> <span style="color:#f0e68c"><strong>case</strong></span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">AUTHENTICATE_MISMATCH</span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹匹配失败,请重新输入'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>case</strong></span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">AUTHENTICATE_OVERLIMIT</span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败次数超出限制,请使用其它方式进行认证'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#f0e68c"><strong>default</strong></span><span style="color:#ffffff">:</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">nativeUI</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alert</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'指纹识别失败('</span><span style="color:#ffffff">+</span><span style="color:#ffffff">e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">code</span><span style="color:#ffffff">+</span><span style="color:#ffa0a0">'),请重试'</span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong>break</strong></span><span style="color:#ffffff">;</span> <span style="color:#ffffff">}</span> <span style="color:#ffffff">});</span> <span style="color:#ffffff">}</span><span style="color:#ffffff"> document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span><span style="color:#ffa0a0">'plusready'</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> plusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span><span style="color:#ffffff">);</span> <span style="color:#f0e68c"><strong></script></strong></span> <span style="color:#f0e68c"><strong></head></strong></span> <span style="color:#f0e68c"><strong><body</strong></span> <span style="color:#f0e68c"><strong>></strong></span><span style="color:#ffffff"> 指纹识别认证 </span><span style="color:#f0e68c"><strong></body></strong></span> <span style="color:#f0e68c"><strong></html></strong></span></code></span></span>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。