App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-10-22 40711118c33369ccad7ceda0fdd729bd9f117f65
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="HandheldFriendly" content="true">
<meta name="MobileOptimized" content="320">
<title>Runtime Document</title>
<link rel="stylesheet" type="text/css" href="res/doc.css" charset="utf-8">
<link rel="stylesheet" type="text/css" href="res/prettify.sons.css" charset="utf-8">
<script type="text/javascript" src="res/doc.js" charset="utf-8"></script><script type="text/javascript" src="res/prettify.js" charset="utf-8"></script>
</head>
<body><div id="content" class="content">
<h1><a name="plus.runtime">runtime</a></h1>
<p>Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。</p>
<h2>属性:</h2>
<ul>
<li>
<a href="#plus.runtime.appid">appid</a>: 当前应用的APPID</li>
<li>
<a href="#plus.runtime.arguments">arguments</a>: 第三方程序调用时传递给程序的参数</li>
<li>
<a href="#plus.runtime.channel">channel</a>: 应用的渠道标识</li>
<li>
<a href="#plus.runtime.launcher">launcher</a>: 应用启动来源</li>
<li>
<a href="#plus.runtime.origin">origin</a>: 应用安装来源</li>
<li>
<a href="#plus.runtime.version">version</a>: 客户端的版本名称</li>
<li>
<a href="#plus.runtime.versionCode">versionCode</a>: 客户端的版本号</li>
<li>
<a href="#plus.runtime.innerVersion">innerVersion</a>: 客户端5+运行环境的内部版本号</li>
<li>
<a href="#plus.runtime.uniVersion">uniVersion</a>: 客户端uni-app运行环境的版本号</li>
<li>
<a href="#plus.runtime.launchLoadedTime">launchLoadedTime</a>: 获取当前应用首页加载的时间</li>
<li>
<a href="#plus.runtime.processId">processId</a>: 获取当前应用的进程标识</li>
<li>
<a href="#plus.runtime.startupTime">startupTime</a>: 获取当前应用的启动时间戳</li>
<li>
<a href="#plus.runtime.isRecovery">isRecovery</a>: 应用是否由于内核崩溃自动恢复</li>
</ul>
<h2>方法:</h2>
<ul>
<li>
<a href="#plus.runtime.getProperty">getProperty</a>: 获取指定APPID对应的应用信息</li>
<li>
<a href="#plus.runtime.install">install</a>: 安装应用</li>
<li>
<a href="#plus.runtime.quit">quit</a>: 退出应用</li>
<li>
<a href="#plus.runtime.restart">restart</a>: 重启当前的应用</li>
<li>
<a href="#plus.runtime.setBadgeNumber">setBadgeNumber</a>: 设置程序快捷方式图标上显示的角标数字</li>
<li>
<a href="#plus.runtime.openURL">openURL</a>: 调用第三方程序打开指定的URL</li>
<li>
<a href="#plus.runtime.openWeb">openWeb</a>: 使用内置Webview窗口打开URL</li>
<li>
<a href="#plus.runtime.openFile">openFile</a>: 调用第三方程序打开指定的文件</li>
<li>
<a href="#plus.runtime.processDirectPage">processDirectPage</a>: 处理直达页面链接参数</li>
<li>
<a href="#plus.runtime.launchApplication">launchApplication</a>: 调用第三方程序</li>
<li>
<a href="#plus.runtime.isApplicationExist">isApplicationExist</a>: 判断第三方程序是否已存在</li>
<li>
<a href="#plus.runtime.isCustomLaunchPath">isCustomLaunchPath</a>: 判断是否自定义应用启动页面加载地址</li>
</ul>
<h2>对象:</h2>
<ul>
<li>
<a href="#plus.runtime.ApplicationInf">ApplicationInf</a>: JSON对象,打开第三方程序参数</li>
<li>
<a href="#plus.runtime.BadgeOptions">BadgeOptions</a>: JSON对象,应用角标显示需要的通知栏消息的参数</li>
<li>
<a href="#plus.runtime.OpenFileOptions">OpenFileOptions</a>: JSON对象,打开文件参数</li>
<li>
<a href="#plus.runtime.WidgetInfo">WidgetInfo</a>: JSON对象,应用信息</li>
<li>
<a href="#plus.runtime.WidgetOptions">WidgetOptions</a>: JSON对象,应用安装参数</li>
</ul>
<h2>回调方法:</h2>
<ul>
<li>
<a href="#plus.runtime.InstallSuccessCallback">InstallSuccessCallback</a>: 安装应用成功回调函数</li>
<li>
<a href="#plus.runtime.InstallErrorCallback">InstallErrorCallback</a>: 安装应用失败回调函数</li>
<li>
<a href="#plus.runtime.GetPropertyCallBack">GetPropertyCallBack</a>: 获取应用属性成功回调函数</li>
<li>
<a href="#plus.runtime.OpenErrorCallback">OpenErrorCallback</a>: 打开本地文件或URL失败回调函数</li>
<li>
<a href="#plus.runtime.LaunchErrorCallback">LaunchErrorCallback</a>: 调用第三方程序失败回调函数</li>
</ul>
<h2>权限:</h2>
<p>5+功能模块(permissions)</p>
<pre class="prettyprint linenums">
{
// ...
"permissions":{
    // ...
    "Runtime": {
        "description": "运行环境"
    }
}
}
            </pre>
<h1><a name="plus.runtime.ApplicationInf">ApplicationInf</a></h1>
<p>JSON对象,打开第三方程序参数</p>
<h2>属性:</h2>
<ul>
<li>pname: <em>(<font class="type">String</font>
    类型
)</em>第三方程序包名<br><p>仅Android平台支持,表示程序的包名,其它平台忽略此属性值。</p>
</li>
<li>action: <em>(<font class="type">String</font>
    类型
)</em>程序的操作行为<br><p>Android平台上与系统的action值一致;iOS平台为要调用程序的URLScheme格式字符串。</p>
</li>
<li>newTask: <em>(<font class="type">Boolean</font>
    类型
)</em>新任务模式标记<br><p>
    可取值:
        true-使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用;
        false-不使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用。
    默认值为true。
    注意:由于5+应用配置的launchMode为singleTask,所以另一个5+应用通过plus.runtime.launchApplication启动时如果应用已经在后台运行则不会触发newintent事件,为了避免此问题需要将newTask参数值设置为false。
                        </p>
</li>
<li>extra: <em>(<font class="type">JSON</font>
    类型
)</em>调用程序的参数<br><p>仅Android平台支持,为JSON格式,用于传递给要调用程序的参数,如extra:{url:"http://www.html5plus.org"}。</p>
</li>
</ul>
<h1><a name="plus.runtime.BadgeOptions">BadgeOptions</a></h1>
<p>JSON对象,应用角标显示需要的通知栏消息的参数</p>
<h2>属性:</h2>
<ul>
<li>title: <em>(<font class="type">String</font>
    类型
)</em>消息的标题<br><p>
    默认值为应用的名称。
                        </p>
</li>
<li>content: <em>(<font class="type">String</font>
    类型
)</em>消息的内容<br><p>
    默认值为“您有x条未读消息"”,其中x未设置的角标数字值。
                        </p>
</li>
</ul>
<h1><a name="plus.runtime.OpenFileOptions">OpenFileOptions</a></h1>
<p>JSON对象,打开文件参数</p>
<h2>属性:</h2>
<ul>
<li>pname: <em>(<font class="type">String</font>
    类型
)</em>优先使用的程序包名<br><p>
    如果指定包名的程序已经安装,则调用其打开文件,若程序不支持打开文件则触发错误回调。
    如果指定包名的程序未安装,则弹出系统支持打开此文件的列表,由用户选择程序打开。
                        </p>
</li>
<li>popover: <em>(<font class="type">json</font>
    类型
)</em>弹出系统选择程序界面指示区域<br><p>
    JSON对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,左上坐标相对于容器webview的位置。仅在iPad设备平台有效。
                        </p>
</li>
</ul>
<h1><a name="plus.runtime.WidgetInfo">WidgetInfo</a></h1>
<p>JSON对象,应用信息</p>
<h2>属性:</h2>
<ul>
<li>appid: <em>(<font class="type">String</font>
    类型
)</em>应用的APPID<br><p>
    对应manifest.json中的id字段值。
                        </p>
</li>
<li>version: <em>(<font class="type">String</font>
    类型
)</em>应用的版本名称<br><p>
    对应manifest.json中的version-&gt;name字段值。
                        </p>
</li>
<li>versionCode: <em>(<font class="type">String</font>
    类型
)</em>应用的版本号<br><p>
    对应manifest.json中的version-&gt;code字段值。
                        </p>
</li>
<li>name: <em>(<font class="type">String</font>
    类型
)</em>应用的名称<br><p>
    对应manifest.json中的name字段值。
                        </p>
</li>
<li>description: <em>(<font class="type">String</font>
    类型
)</em>应用描述信息<br><p>
    对应manifest.json中的description字段值。
                        </p>
</li>
<li>author: <em>(<font class="type">String</font>
    类型
)</em>应用描述信息<br><p>
    对应manifest.json中的developer-&gt;name字段值。
                        </p>
</li>
<li>email: <em>(<font class="type">String</font>
    类型
)</em>开发者邮箱地址<br><p>
    对应manifest.json中的developer-&gt;email字段值。
                        </p>
</li>
<li>features: <em>(<font class="type">String[]</font>
    类型
)</em>应用许可特性列表<br><p>
    对应manifest.json中的permissions字段下所有键名的列表。
                        </p>
</li>
</ul>
<h1><a name="plus.runtime.WidgetOptions">WidgetOptions</a></h1>
<p>JSON对象,应用安装参数</p>
<h2>说明:</h2>
<p class="des">可通过对象设置安装的应用是否进行appid校验、版本号校验等。</p>
<h2>属性:</h2>
<ul><li>force: <em>(<font class="type">Boolean</font>
    类型
)</em>是否强制安装<br><p>
    true表示强制安装,不进行版本号的校验;false则需要版本号校验,如果将要安装应用的版本号不高于现有应用的版本号则终止安装,并返回安装失败。
    仅安装wgt和wgtu时生效,默认值 false。
                        </p>
</li></ul>
<h1><a name="plus.runtime.InstallSuccessCallback">InstallSuccessCallback</a></h1>
<p>安装应用成功回调函数</p>
<pre class="prettyprint linenums">
void onSuccess(widgetInfo){
    // Code here
}
                </pre>
<h2>参数:</h2>
<ul><li>widgetInfo: 
        <em>(
            <font class="type">WidgetInfo</font>
            )
            必选 </em><br>应用信息,参见:WidgetInfo</li></ul>
<h2>返回值:</h2>
<font class="type">void</font>
            : 无<h1><a name="plus.runtime.InstallErrorCallback">InstallErrorCallback</a></h1>
<p>安装应用失败回调函数</p>
<pre class="prettyprint linenums">
void onError(error){
    // Handle the error
}
                </pre>
<h2>参数:</h2>
<ul><li>error: 
        <em>(
            <font class="type">DOMException</font>
            )
            必选 </em><br>安装失败的错误信息</li></ul>
<h2>返回值:</h2>
<font class="type">void</font>
            : 无<h1><a name="plus.runtime.GetPropertyCallBack">GetPropertyCallBack</a></h1>
<p>获取应用属性成功回调函数</p>
<pre class="prettyprint linenums">
void onGetPropertyCB(widgetInfo){
    // Code here
}
                </pre>
<h2>参数:</h2>
<ul><li>widgetInfo: 
        <em>(
            <a href="#plus.runtime.WidgetInfo">WidgetInfo</a>
            )
            必选 </em>应用信息<br>
    包括应用名称、标识等属性。
                        </li></ul>
<h2>返回值:</h2>
<font class="type">void</font>
            : 无<h1><a name="plus.runtime.OpenErrorCallback">OpenErrorCallback</a></h1>
<p>打开本地文件或URL失败回调函数</p>
<pre class="prettyprint linenums">
void onError(error){
    // Handle the error
}
                </pre>
<h2>参数:</h2>
<ul><li>error: 
        <em>(
            <font class="type">DOMException</font>
            )
            必选 </em><br>打开操作失败的错误信息</li></ul>
<h2>返回值:</h2>
<font class="type">void</font>
            : 无<h1><a name="plus.runtime.LaunchErrorCallback">LaunchErrorCallback</a></h1>
<p>调用第三方程序失败回调函数</p>
<pre class="prettyprint linenums">
void onError(error){
    // Handle the error
}
                </pre>
<h2>参数:</h2>
<ul><li>error: 
        <em>(
            <font class="type">DOMException</font>
            )
            必选 </em>操作失败的错误信息<br>
    可通过error.code(Number类型)获取错误编码;
    可通过error.message(String类型)获取错误描述信息。
                        </li></ul>
<h2>返回值:</h2>
<font class="type">void</font>
            : 无<br><br>
</div></body>
</html>