Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Oct 19, 2016
1 parent 8a7f4c0 commit 76859b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
25 changes: 22 additions & 3 deletions cordova_fcm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
and iOS.
*)

(** {b Types} *)
(** The three following types are defined to have clearer functions signatures.
They are not abstract because it is not necessary.
*)
Expand All @@ -37,9 +38,15 @@ type topic = string
(** Types representing an error returned by FCM *)
type error = string

(** {b Data from "data" payload.} *)

(** The following module defines a type {!Data.t} which contains information
about the notification (which is a JavaScript object). To access to
properties of a value of type {!Data.t}, get functions are implemented.
In cordova-plugin-fcm, these data comes from the "data" payload in the JSON
sent to FCM. See the official documentation:
https://github.com/fechanique/cordova-plugin-fcm
*)
module Data :
sig
Expand Down Expand Up @@ -159,9 +166,12 @@ module Data :
]
end

(** {b Binding to functions.} *)
(** [get_token success_callback error_callback] gets a token from FCM.
If success, the callback [success_callback] is called and the token is given
in the first parameter.
If an error occured, the callback [error_callback] is called and the
error description is given as a string in the first parameter.
*)
Expand All @@ -173,8 +183,10 @@ val get_token :

(** [subscribe_to_topic topic success_callback error_callback] subscribes to the
topic [topic].
If success, the callback [success_callback] is called and a message is given
in the first parameter.
If an error occured, the callback [error_callback] is called and the
error description is given as a string in the first parameter.
*)
Expand All @@ -187,8 +199,10 @@ val subscribe_to_topic :

(** [unsubscribe_to_topic topic success_callback error_callback] unsubscribes to
the topic [topic].
If success, the callback [success_callback] is called and a message is given
in the first parameter.
If an error occured, the callback [error_callback] is called and the
error description is given as a string in the first parameter.
*)
Expand All @@ -204,13 +218,18 @@ val unsubscribe_from_topic :
will be executed when the device will receive a notification. A [Data.t]
value is given in first parameter which contains keys sent by FCM. You can
get any key values by using the appropriate [Data.get] functions. Wrappers
for built-in OCaml types like get_string, get_bool, get_int, get_int64 are
for built-in OCaml types like {!Data.get_string}, {!Data.get_bool},
{!Data.get_int}, {!Data.get_int64} are
defined to avoid using a cast function.
[success_registered] will be executed if the onNotification callback is
[success_registered] will be executed if the [onNotification] callback is
successfully registered.
[error_registered] will be executed if the onNotification callback failed to
[error_registered] will be executed if the [onNotification] callback failed to
register.
{b NOTE}: Don't forget to set the "action" payload in notification to
"ACTIVITY_PLUGIN_FCM" if you want to open the application when
the user taps on the notification.
*)
val on_notification :
(Data.t -> unit) ->
Expand Down
7 changes: 6 additions & 1 deletion doc/Cordova_fcm.Data.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ <h1>Module <a href="type_Cordova_fcm.Data.html">Cordova_fcm.Data</a></h1>
<pre><span class="keyword">module</span> Data: <code class="code">sig</code> <a href="Cordova_fcm.Data.html">..</a> <code class="code">end</code></pre><div class="info module top">
The following module defines a type <a href="Cordova_fcm.Data.html#TYPEt"><code class="code">Cordova_fcm.Data.t</code></a> which contains information
about the notification (which is a JavaScript object). To access to
properties of a value of type <a href="Cordova_fcm.Data.html#TYPEt"><code class="code">Cordova_fcm.Data.t</code></a>, get functions are implemented.<br>
properties of a value of type <a href="Cordova_fcm.Data.html#TYPEt"><code class="code">Cordova_fcm.Data.t</code></a>, get functions are implemented.
<p>

In cordova-plugin-fcm, these data comes from the "data" payload in the JSON
sent to FCM. See the official documentation:
https://github.com/fechanique/cordova-plugin-fcm<br>
</div>
<hr width="100%">

Expand Down
32 changes: 28 additions & 4 deletions doc/Cordova_fcm.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ <h1>Module <a href="type_Cordova_fcm.html">Cordova_fcm</a></h1>
</div>
<hr width="100%">
<br>
<b>Types</b><br>
<br>
The three following types are defined to have clearer functions signatures.
They are not abstract because it is not necessary.<br>

Expand All @@ -42,34 +44,50 @@ <h1>Module <a href="type_Cordova_fcm.html">Cordova_fcm</a></h1>
Types representing an error returned by FCM<br>
</div>

<br>
<b>Data from "data" payload.</b><br>

<pre><span class="keyword">module</span> <a href="Cordova_fcm.Data.html">Data</a>: <code class="code">sig</code> <a href="Cordova_fcm.Data.html">..</a> <code class="code">end</code></pre><div class="info">
The following module defines a type <a href="Cordova_fcm.Data.html#TYPEt"><code class="code">Cordova_fcm.Data.t</code></a> which contains information
about the notification (which is a JavaScript object).
</div>
<br>
<b>Binding to functions.</b><br>

<pre><span id="VALget_token"><span class="keyword">val</span> get_token</span> : <code class="type">(<a href="Cordova_fcm.html#TYPEtoken">token</a> -> unit) -> (<a href="Cordova_fcm.html#TYPEerror">error</a> -> unit) -> unit</code></pre><div class="info ">
<code class="code">get_token success_callback error_callback</code> gets a token from FCM.
<p>

If success, the callback <code class="code">success_callback</code> is called and the token is given
in the first parameter.
<p>

If an error occured, the callback <code class="code">error_callback</code> is called and the
error description is given as a string in the first parameter.<br>
</div>

<pre><span id="VALsubscribe_to_topic"><span class="keyword">val</span> subscribe_to_topic</span> : <code class="type"><a href="Cordova_fcm.html#TYPEtopic">topic</a> -> (string -> unit) -> (<a href="Cordova_fcm.html#TYPEerror">error</a> -> unit) -> unit</code></pre><div class="info ">
<code class="code">subscribe_to_topic topic success_callback error_callback</code> subscribes to the
topic <code class="code">topic</code>.
<p>

If success, the callback <code class="code">success_callback</code> is called and a message is given
in the first parameter.
<p>

If an error occured, the callback <code class="code">error_callback</code> is called and the
error description is given as a string in the first parameter.<br>
</div>

<pre><span id="VALunsubscribe_from_topic"><span class="keyword">val</span> unsubscribe_from_topic</span> : <code class="type"><a href="Cordova_fcm.html#TYPEtopic">topic</a> -> (string -> unit) -> (<a href="Cordova_fcm.html#TYPEerror">error</a> -> unit) -> unit</code></pre><div class="info ">
<code class="code">unsubscribe_to_topic topic success_callback error_callback</code> unsubscribes to
the topic <code class="code">topic</code>.
<p>

If success, the callback <code class="code">success_callback</code> is called and a message is given
in the first parameter.
<p>

If an error occured, the callback <code class="code">error_callback</code> is called and the
error description is given as a string in the first parameter.<br>
</div>
Expand All @@ -80,13 +98,19 @@ <h1>Module <a href="type_Cordova_fcm.html">Cordova_fcm</a></h1>
will be executed when the device will receive a notification. A <code class="code">Data.t</code>
value is given in first parameter which contains keys sent by FCM. You can
get any key values by using the appropriate <code class="code">Data.get</code> functions. Wrappers
for built-in OCaml types like get_string, get_bool, get_int, get_int64 are
for built-in OCaml types like <a href="Cordova_fcm.Data.html#VALget_string"><code class="code">Cordova_fcm.Data.get_string</code></a>, <a href="Cordova_fcm.Data.html#VALget_bool"><code class="code">Cordova_fcm.Data.get_bool</code></a>,
<a href="Cordova_fcm.Data.html#VALget_int"><code class="code">Cordova_fcm.Data.get_int</code></a>, <a href="Cordova_fcm.Data.html#VALget_int64"><code class="code">Cordova_fcm.Data.get_int64</code></a> are
defined to avoid using a cast function.
<p>

<code class="code">success_registered</code> will be executed if the onNotification callback is
<code class="code">success_registered</code> will be executed if the <code class="code">onNotification</code> callback is
successfully registered.
<code class="code">error_registered</code> will be executed if the onNotification callback failed to
register.<br>
<code class="code">error_registered</code> will be executed if the <code class="code">onNotification</code> callback failed to
register.
<p>

<b>NOTE</b>: Don't forget to set the "action" payload in notification to
"ACTIVITY_PLUGIN_FCM" if you want to open the application when
the user taps on the notification.<br>
</div>
</body></html>

0 comments on commit 76859b1

Please sign in to comment.