App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-10-09 2b8231f5da82c56c3315d1cf5b126688ea3d501e
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
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="HandheldFriendly" content="true"/>
        <meta name="MobileOptimized" content="320"/>
        <title>Hello H5+</title>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript">
function getVersion(){
    outSet("程序版本名称:"+plus.runtime.version+"\n程序版本号:"+plus.runtime.versionCode+"\n内核版本号:"+plus.runtime.innerVersion+"\nuni-app运行环境:"+plus.runtime.uniVersion);
}
function getArguments(){
    outSet("启动方式: "+plus.runtime.launcher+"\n启动参数: "+plus.runtime.arguments);
}
function getChannel(){
    outSet("Channel: "+plus.runtime.channel);
}
function restartApp() {
    plus.runtime.restart();
}
function getWidgetInfo() {
    plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
        //appid属性
        var wgtStr = "appid:"+wgtinfo.appid;
        //version属性
        wgtStr += "\nversion:"+wgtinfo.version;
        wgtStr += "\nversionCode:"+wgtinfo.versionCode;
        //name属性
        wgtStr += "\nname:"+wgtinfo.name;
        //description属性
        wgtStr += "\ndescription:"+wgtinfo.description;
        //author属性
        wgtStr += "\nauthor:"+wgtinfo.author;
        //email属性
        wgtStr += "\nemail:"+wgtinfo.email;
        //features 属性
        wgtStr += "\nfeatures:"+wgtinfo.features;
        outSet( wgtStr );
    } );
}
function setBadge() {
    plus.runtime.setBadgeNumber( 50 );
    outSet( "设置程序图标右上角显示的提示数字为50\n请返回桌面查看" );
    if(plus.os.name=="iOS"){
        outLine( '*如果无法设置提示数字,请到"设置"->"通知"中配置应用在通知中心显示!' );
    }else{
        outLine( "注:仅支持小米(MIUI v5),其它设备暂不支持此功能!" );
    }
}
function clearBadge() {
    plus.runtime.setBadgeNumber( 0 );
    outSet( "清除程序图标右上角显示的提示数字\n请返回桌面查看" );
    if(plus.os.name=="iOS"){
        outLine( '如果无法清除提示数字,请到"设置"->"通知"中配置应用在通知中心显示!' );
    }else{
        outLine( "注:仅支持小米(MIUI v5),其它设备暂不支持此功能!" );
    }
}
function exitApp(){
    if(plus.os.name=="Android"){
        plus.runtime.quit();
    }else{
        outSet( "此平台不支持直接退出程序,请按Home键切换应用" );
    }
}
function updateApp(){
    var url='http://demo.dcloud.net.cn/helloh5/update/HelloH5.wgtu';
    plus.nativeUI.showWaiting("升级中...");
    var dtask = plus.downloader.createDownload( url, {method:"GET"}, function(d,status){
        if ( status == 200 ) { 
            console.log( "Download wgtu success: " + d.filename );
            plus.runtime.install(d.filename,{},function(){
                plus.nativeUI.closeWaiting();
                plus.nativeUI.alert("Update wgtu success, restart now!",function(){
                    plus.runtime.restart();
                });
            },function(e){
                plus.nativeUI.closeWaiting();
                alert("Update wgtu failed: "+e.message);
            });
        } else {
            plus.nativeUI.closeWaiting();
             alert( "Download wgtu failed: " + status ); 
        } 
    } );
    dtask.addEventListener('statechanged',function(d,status){
        console.log("statechanged: "+d.state);
    });
    dtask.start();
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
    </head>
    <body>
        <br/>
        <div class="button" onclick="clicked('runtime_launch.html',true);">
            调用第三方程序
        </div>
        <br/>
        <ul class="dlist">
            <li class="ditem" onclick="getVersion()">获取版本信息</li>
            <li class="ditem" onclick="getArguments()">获取启动信息</li>
            <li class="ditem" onclick="getChannel()">获取渠道信息</li>
            <li class="ditem" onclick="restartApp()">重启当前应用</li>
            <li class="ditem" onclick="getWidgetInfo()">获取当前应用的基本属性</li>
            <li class="ditem" onclick="setBadge()">设置程序图标右上角数字</li>
            <li class="ditem" onclick="clearBadge()">清除程序图标右上角数字</li>
            <li class="ditem" onclick="exitApp()">退出当前应用</li>
            <!--li class="ditem" onclick="updateApp()">WGTU Update</li-->
        </ul>
        <div id="outpos"/>
        <div id="output">
Runtime管理程序运行时环境,可用于获取程序的各种信息、与第三方程序通讯等。
        </div>
    </body>
</html>