blob: 9418c598cc4628dcd6ebdea13a666daf28a4ecf3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
---
title: Navigator.mozSetMessageHandler()
slug: Archive/B2G_OS/API/Navigator/mozSetMessageHandler
translation_of: Archive/B2G_OS/API/Navigator/mozSetMessageHandler
---
<p></p><section class="Quick_links" id="Quick_Links"><ol><li><strong><a href="/zh-CN/docs/Web/API/Archive"><code>Archive</code></a></strong></li><li class="toggle"><details open><summary>Related pages for Firefox OS</summary><ol><li><a href="/zh-CN/docs/Web/API/MozAlarmsManager"><code>MozAlarmsManager</code></a></li><li><a href="/zh-CN/docs/Web/API/MozMobileNetworkInfo"><code>MozMobileNetworkInfo</code></a></li><li><a href="/zh-CN/docs/Web/API/MozWifiP2pGroupOwner"><code>MozWifiP2pGroupOwner</code></a></li></ol></details></li></ol></section><div class="warning">
<p style="text-align: center;">此 API 在 <a href="/zh-CN/docs/Mozilla/Firefox_OS">Firefox OS</a> 的<a href="/zh-CN/docs/Mozilla/Firefox_OS/Security/Application_security#App_Types">网页内容或高权限的应用程序</a>上可用。</p>
</div><p></p>
<h2 id="概要">概要</h2>
<p>该方法用来允许应用为系统消息注册处理程序,对消息作出反应。</p>
<p>任何应用都允许注册到任何消息,但一些消息仅仅可以被送到有对应接收权限的应用。不同于DOM事件,如果应用没有针对系统消息的处理程序,它们将留在队列里。如果有排队消息,可以传入一个type参数调用<a href="/zh-CN/docs/Web/API/Window/navigator/mozHasPendingMessage" title="此页面仍未被本地化, 期待您的翻译!"><code>navigator.mozHasPendingMessage()</code></a>查看,当一个处理程序被设置,待处理消息将异步的地发送到应用。</p>
<h2 id="语法">语法</h2>
<pre>navigator.mozSetMessageHandler(type, handler);</pre>
<h3 id="参数">参数<span id="cke_bm_102S" style="display: none;"> </span></h3>
<dl>
<dt> </dt>
<dt><code><span id="cke_bm_83S" style="display: none;"> </span>type</code></dt>
<dd>type是一个字符串,表示要为其注册处理函数的一类消息。</dd>
<dt><code>handler</code></dt>
<dd>当系统发送消息时,该处理函数被调用,其接收参数由消息类型来确定。</dd>
</dl>
<h2 id="Specification" name="Specification">消息类型</h2>
<p>目前Firefox OS允许注册以下消息 :</p>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Message name</th>
<th scope="col">Handler signature</th>
<th scope="col">Permission</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>activity</code></td>
<td><code>f( <a href="/zh-CN/docs/Web/API/MozActivityRequestHandler" title="此页面仍未被本地化, 期待您的翻译!"><code>MozActivityRequestHandler</code></a> request )</code></td>
<td> </td>
</tr>
<tr>
<td><code>alarm</code></td>
<td><code>f( object unknown )</code></td>
<td>alarms</td>
</tr>
<tr>
<td><code>bluetooth-cancel</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-dialer-command</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-hfp-status-changed</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-opp-transfer-start</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-opp-transfer-complete</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-opp-receiving-file-confirmation</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-opp-update-progress</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-pairedstatuschanged</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-requestconfirmation</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-requestpincode</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>bluetooth-requestpasskey</code></td>
<td><code>f( object unknown )</code></td>
<td>bluetooth</td>
</tr>
<tr>
<td><code>headset-button</code></td>
<td><code>f( object unknown )</code></td>
<td> </td>
</tr>
<tr>
<td><code>icc-stkcommand</code></td>
<td><code>f( object command )</code></td>
<td>settings</td>
</tr>
<tr>
<td><code>notification</code></td>
<td><code>f( object unknown )</code></td>
<td> </td>
</tr>
<tr>
<td><code>push</code></td>
<td><code>f( object <a href="/en-US/docs/WebAPI/Simple_Push#Add_the_push_message_handler">registration</a> )</code></td>
<td><code>push</code></td>
</tr>
<tr>
<td><code>push-register</code></td>
<td><code>f ( )</code></td>
<td><code>push</code></td>
</tr>
<tr>
<td><code>sms-received</code></td>
<td><code>f( <a href="/zh-CN/docs/Web/API/SmsMessage" title="此页面仍未被本地化, 期待您的翻译!"><code>SmsMessage</code></a> sms )</code></td>
<td style="white-space: nowrap;">sms</td>
</tr>
<tr>
<td><code>sms-sent</code></td>
<td><code>f( <a href="/zh-CN/docs/Web/API/SmsMessage" title="此页面仍未被本地化, 期待您的翻译!"><code>SmsMessage</code></a> sms )</code></td>
<td>sms</td>
</tr>
<tr>
<td><code>telephony-call-ended</code></td>
<td><code>f( object call )</code></td>
<td>telephony</td>
</tr>
<tr>
<td><code>telephony-new-call</code></td>
<td><code>f( )</code></td>
<td>telephony</td>
</tr>
<tr>
<td><code>ussd-received</code></td>
<td><code>f( object ussd )</code></td>
<td>mobileconnection</td>
</tr>
<tr>
<td><code>wappush-received</code></td>
<td><code>f( object wappush )</code></td>
<td>wappush</td>
</tr>
</tbody>
</table>
<h2 id="规范说明">规范说明</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><a class="external" hreflang="en" lang="en" title="Unknown">Unknown</a></td>
<td><span class="spec-">Unknown</span></td>
<td>Defines the system messaging interfaces.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p></p><p class="warning"><strong><a href="https://github.com/mdn/browser-compat-data">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables">Find out how you can help!</a></strong></p>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div><p></p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari (WebKit)</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Firefox OS</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #f00;">未实现</span></td>
<td>1.0</td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
<td><span style="color: #f00;">未实现</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="参见">参见</h2>
<ul>
<li><a href="/zh-CN/docs/Web/API/Window/navigator/mozHasPendingMessage" title="此页面仍未被本地化, 期待您的翻译!"><code>navigator.mozHasPendingMessage()</code></a></li>
<li><a href="/en-US/docs/WebAPI/Web_Activities" title="/en-US/docs/WebAPI/Web_Activities">Web Activities</a></li>
<li><a href="https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.webapi/o8bkwx0EtmM" title="https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.webapi/o8bkwx0EtmM">Discussion on the Mozilla WebAPI mailing list.</a></li>
</ul>
|