Confirmed users
1,018
edits
Willyaranda (talk | contribs) No edit summary |
|||
Line 26: | Line 26: | ||
} | } | ||
===requestURL(WAToken, publicKey)=== | |||
to send notifications. | asks the user if they'd like to allow the app requesting to send notifications. If the app has been granted permission already and is calling <tt>requestURL()</tt> again, the original values are returned and no user interaction is required. | ||
==== Arguments ==== | |||
<b><tt>WAToken</tt></b><br> | |||
the Web App Token identifies uniquely the user (or installation) of the app (or a shared <tt>WAToken</tt>, used for broadcast). It is generated by <i style="color:red">XXX</i> | |||
<b><tt>publicKey</tt></b><br> | |||
used to verify the origin of the notification. This is a cryptographic key generated by the app and should be unique per user. | |||
==== Returns ==== | |||
<tt>request.result</tt> will be a "JSON object" with the following structure | |||
dictionary PushURLResult { | dictionary PushURLResult { | ||
Line 38: | Line 46: | ||
DOMString WAtoken; | DOMString WAtoken; | ||
} | } | ||
<b><tt>status</tt></b><br /> | |||
"SUCCESS" on successful registration of <tt>WAToken</tt>, otherwise, "ERROR". | |||
=====SUCCESS parameters ===== | |||
<b><tt>url</tt></b><br /> | |||
returns the URL the app server may use to send a Push Notification messages to the user. | |||
<b><tt>messageType</tt></b><br /> | |||
<tt>registeredWA</tt> response to this message | |||
<b><tt>WAToken</tt></b><br /> | |||
same value as the <tt>WAToken</tt> parameter | |||
=====Error parameters ===== | |||
<b><tt>reason</tt></b><br /> | |||
Optional value which may contain a more explicit message error. | |||
<b><tt>WAtoken</tt></b><br /> | |||
same value as the <tt>WAToken</tt> parameter | |||
The <tt> | ===getCurrentURL()=== | ||
lets the app ask Firefox if the app has a push URL without bothering the user. The function behaves the same way as <tt>requestURL()</tt> except for the case when <tt>requestURL()</tt> would prompt the user. I.e. if the user has already granted permission, or if the user has permanently denied permission, then <tt>getCurrentURL</tt> behaves the same as <tt>requestURL</tt>. However if the user hasn't yet made a decision, then <tt>getCurrentURL</tt> results in a success event, but with <tt>request.result</tt> set to null. | |||
==== Arguments ==== | |||
There are no arguments for this function | |||
==== Returns ==== | |||
This function returns the stored values for <tt>requestURL()</tt> or Null if no stored values exist. | |||
===revokeURL(url)=== | |||
lets the app indicate that it no longer wants to be able to push messages using the indicated URL for this installation. | |||
<tt> | ==== Arguments ==== | ||
<b><tt>url</tt></b><br /> | |||
The URL returned by a previously successful <tt>requestURL()</tt> call. | |||
=== Examples === | |||
Simple usage would look like this: | Simple usage would look like this: | ||