ReCaptcha/Classes/ReCaptcha.html

489 lines
23 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<title>ReCaptcha Class Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset='utf-8'>
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Class/ReCaptcha" class="dashAnchor"></a>
<a title="ReCaptcha Class Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">ReCaptcha Docs</a> (100% documented)</p>
<p class="header-right"><a href="https://github.com/fjcaetano/ReCaptcha"><img src="../img/gh.png"/>View on GitHub</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="../index.html">ReCaptcha Reference</a>
<img id="carat" src="../img/carat.png" />
ReCaptcha Class Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="../Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Classes/ReCaptcha.html">ReCaptcha</a>
</li>
<li class="nav-group-task">
<a href="../Classes/ReCaptcha/Endpoint.html"> Endpoint</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Enums/ReCaptchaError.html">ReCaptchaError</a>
</li>
<li class="nav-group-task">
<a href="../Enums/ReCaptchaResult.html">ReCaptchaResult</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/Reactive.html">Reactive</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>ReCaptcha</h1>
<div class="declaration">
<div class="language">
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">ReCaptcha</span></code></pre>
</div>
</div>
</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC8EndpointO"></a>
<a name="//apple_ref/swift/Enum/Endpoint" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC8EndpointO">Endpoint</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>The JS API endpoint to be loaded onto the HTML file.</p>
<a href="../Classes/ReCaptcha/Endpoint.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Endpoint</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC6apiKey7baseURL8endpoint6localeABSSSg_10Foundation0F0VSgAB8EndpointOAH6LocaleVSgtKcfc"></a>
<a name="//apple_ref/swift/Method/init(apiKey:baseURL:endpoint:locale:)" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC6apiKey7baseURL8endpoint6localeABSSSg_10Foundation0F0VSgAB8EndpointOAH6LocaleVSgtKcfc">init(apiKey:baseURL:endpoint:locale:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Initializes a ReCaptcha object</p>
<p>Both <code>apiKey</code> and <code>baseURL</code> may be nil, in which case the lib will look for entries of <code>ReCaptchaKey</code> and
<code>ReCaptchaDomain</code>, respectively, in the project&rsquo;s Info.plist</p>
<p>A key may be aquired here: <a href="https://www.google.com/recaptcha/admin#list">https://www.google.com/recaptcha/admin#list</a></p>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
<code><a href="../Enums/ReCaptchaError.html#/s:9ReCaptcha0aB5ErrorO08htmlLoadC0yA2CmF">ReCaptchaError.htmlLoadError</a></code>: if is unable to load the HTML embedded in the bundle.
</div>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
<code><a href="../Enums/ReCaptchaError.html#/s:9ReCaptcha0aB5ErrorO14apiKeyNotFoundyA2CmF">ReCaptchaError.apiKeyNotFound</a></code>: if an <code>apiKey</code> is not provided and can&rsquo;t find one in the project&rsquo;s
Info.plist.
</div>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
<code><a href="../Enums/ReCaptchaError.html#/s:9ReCaptcha0aB5ErrorO15baseURLNotFoundyA2CmF">ReCaptchaError.baseURLNotFound</a></code>: if a <code>baseURL</code> is not provided and can&rsquo;t find one in the project&rsquo;s
Info.plist.
</div>
<div class="aside aside-throws">
<p class="aside-title">Throws</p>
Rethrows any exceptions thrown by <code>String(contentsOfFile:)</code>
</div>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="n">convenience</span> <span class="nf">init</span><span class="p">(</span>
<span class="nv">apiKey</span><span class="p">:</span> <span class="kt">String</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
<span class="nv">baseURL</span><span class="p">:</span> <span class="kt">URL</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">,</span>
<span class="nv">endpoint</span><span class="p">:</span> <span class="kt"><a href="../Classes/ReCaptcha/Endpoint.html">Endpoint</a></span> <span class="o">=</span> <span class="o">.</span><span class="k">default</span><span class="p">,</span>
<span class="nv">locale</span><span class="p">:</span> <span class="kt">Locale</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span>
<span class="p">)</span> <span class="k">throws</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>apiKey</em>
</code>
</td>
<td>
<div>
<p>The API key sent to the ReCaptcha init</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>infoPlistKey</em>
</code>
</td>
<td>
<div>
<p>The API key retrived from the application&rsquo;s Info.plist</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>baseURL</em>
</code>
</td>
<td>
<div>
<p>The base URL sent to the ReCaptcha init</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>infoPlistURL</em>
</code>
</td>
<td>
<div>
<p>The base URL retrieved from the application&rsquo;s Info.plist</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>locale</em>
</code>
</td>
<td>
<div>
<p>A locale value to translate ReCaptcha into a different language</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC8validate2on12resetOnError10completionySo6UIViewC_SbyAA0aB6ResultOctF"></a>
<a name="//apple_ref/swift/Method/validate(on:resetOnError:completion:)" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC8validate2on12resetOnError10completionySo6UIViewC_SbyAA0aB6ResultOctF">validate(on:resetOnError:completion:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Starts the challenge validation</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">validate</span><span class="p">(</span><span class="n">on</span> <span class="nv">view</span><span class="p">:</span> <span class="kt">UIView</span><span class="p">,</span> <span class="nv">resetOnError</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/ReCaptchaResult.html">ReCaptchaResult</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>view</em>
</code>
</td>
<td>
<div>
<p>The view that should present the webview.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>resetOnError</em>
</code>
</td>
<td>
<div>
<p>If ReCaptcha should be reset if it errors. Defaults to <code>true</code>.</p>
</div>
</td>
</tr>
<tr>
<td>
<code>
<em>completion</em>
</code>
</td>
<td>
<div>
<p>A closure that receives a ReCaptchaResult which may contain a valid result token.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC4stopyyF"></a>
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC4stopyyF">stop()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Stops the execution of the webview</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC16configureWebViewyyySo05WKWebE0CcF"></a>
<a name="//apple_ref/swift/Method/configureWebView(_:)" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC16configureWebViewyyySo05WKWebE0CcF">configureWebView(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Provides a closure to configure the webview for presentation if necessary.</p>
<p>If presentation is required, the webview will already be a subview of <code>presenterView</code> if one is provided. Otherwise
it might need to be added in a view currently visible.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">configureWebView</span><span class="p">(</span><span class="n">_</span> <span class="nv">configure</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">WKWebView</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>
</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>configure</em>
</code>
</td>
<td>
<div>
<p>A closure that receives an instance of <code>WKWebView</code> for configuration.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC5resetyyF"></a>
<a name="//apple_ref/swift/Method/reset()" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC5resetyyF">reset()</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Resets the ReCaptcha.</p>
<p>The reset is achieved by calling <code>grecaptcha.reset()</code> on the JS API.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">reset</span><span class="p">()</span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<div class="task-name-container">
<a name="/Development"></a>
<a name="//apple_ref/swift/Section/Development" class="dashAnchor"></a>
<a href="#/Development">
<h3 class="section-name">Development</h3>
</a>
</div>
<ul>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC21forceVisibleChallengeSbvp"></a>
<a name="//apple_ref/swift/Property/forceVisibleChallenge" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC21forceVisibleChallengeSbvp">forceVisibleChallenge</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Forces the challenge widget to be explicitly displayed.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">forceVisibleChallenge</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:9ReCaptchaAAC18shouldSkipForTestsSbvp"></a>
<a name="//apple_ref/swift/Property/shouldSkipForTests" class="dashAnchor"></a>
<a class="token" href="#/s:9ReCaptchaAAC18shouldSkipForTestsSbvp">shouldSkipForTests</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Allows validation stubbing for testing</p>
<p>When this property is set to <code>true</code>, every call to <code>validate()</code> will immediately be resolved with <code>.token(&quot;&quot;)</code>.</p>
<p>Use only when testing your application.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">shouldSkipForTests</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2018 <a class="link" href="https://github.com/fjcaetano" target="_blank" rel="external">Flávio Caetano (@fjcaetano)</a>. All rights reserved. (Last updated: 2018-09-28)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>