It depends on your API, but usually your API would store that when the App 
registered to receive the information. In the gecko parts of your API you can 
get the App information from the message manager (assuming that you have split 
your API into a child & parent part).

For example, in the network stats API, when a page sets and an alarm by calling 
networkstats.addAlarm() [1], the DOM implementation in the child [2] sends a 
message (“NetworkStats:SetAlarm”) to the parent part of the API. In the parent 
[3], it pulls the app information off the message, and stores it with the alarm 
details.  Later the networkstats-alarm is subsequently sent using the 
information that was stored earlier [4].

There are other ways you can get the app details, for example, if you just need 
it in the child you usually do something like this [5]

Hope that helps.

[1] 
https://developer.mozilla.org/en-US/docs/Web/API/MozNetworkStatsManager/addAlarm
 
<https://developer.mozilla.org/en-US/docs/Web/API/MozNetworkStatsManager/addAlarm>
[2] 
http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsManager.js#200
 
<http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsManager.js#200>
[3] 
http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsService.jsm#986
 
<http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsService.jsm#986>
[4] 
http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsService.jsm#1158
 
<http://mxr.mozilla.org/mozilla-central/source/dom/network/NetworkStatsService.jsm#1158>
[5] 
https://dxr.mozilla.org/mozilla-central/source/dom/inputmethod/MozKeyboard.js#634
 
<https://dxr.mozilla.org/mozilla-central/source/dom/inputmethod/MozKeyboard.js#634>
 



> On 7 Jan 2016, at 12:45 pm, Sammy Patenotte <[email protected]> wrote:
> 
> Hi Paul, sorry to bother you again!
> I've checked the system messages API, and think it's a perfect fit for me! 
> Now I'm almost done implementing it, but there is just one thing I can't 
> figure out.
> To use the sendMessage() function I need to have the recipient's Manifest 
> URI, which I don't know how to figure out.
> The sendMessage function's parameters are:
>  /*
>   * Allow any internal user to send a message of a given type to a given page
>   * of an app. The message will be sent to all the registered pages of the app
>   * when |pageURI| is not specified.
>   * @param type        The type of the message to be sent.
>   * @param message     The message payload.
>   * @param pageURI     The URI of the page that will be opened. Nullable.
>   * @param manifestURI The webapp's manifest URI.
>   * @param extra       Extra opaque information that will be passed around in 
> the observer
>   *                    notification to open the page.
>   * returns a Promise
>   */
>  nsISupports sendMessage(in DOMString type, in jsval message,
>                          in nsIURI pageURI, in nsIURI manifestURI,
>                          [optional] in jsval extra);
> 
> I have found some methods that might be able to help me but I don't really 
> know how to use them. They're in 
> B2G/gecko/dom/interfaces/apps/nsIAppsService.idl.
> For example :
>  /**
>   * Returns the manifest URL associated to this localId.
>   */
>  DOMString getManifestURLByLocalId(in unsigned long localId);
> 
> But I don't know how to get the local id.
> 
> If you have any idea how to do this, that would be awesome!
> 
> Thanks,
> Sammy.
> _______________________________________________
> dev-fxos mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-fxos

_______________________________________________
dev-fxos mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-fxos

Reply via email to