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
<!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">
var shares=null;
// H5 plus事件处理
function plusReady(){
    // 延时获取服务列表,避免影响窗口动画
    setTimeout(updateSerivces, 500);
}
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready', plusReady, false);
}
/**
 * 更新分享服务
 */
function updateSerivces(){
    plus.share.getServices(function(s){
        shares={};
        for(var i in s){
            var t=s[i];
            shares[t.id]=t;
        }
    }, function(e){
        outSet('获取分享服务列表失败:'+e.message);
    });
}
/**
 * 调用系统分享
  */
function shareSystem(){
    outSet('调用系统分享');
    var msg={content:sharecontent.value};
    if('iOS'==plus.os.name){//iOS平台添加链接地址
        msg.href='http://www.dcloud.io/';
    }
    outLine(JSON.stringify(msg));
    plus.share.sendWithSystem?plus.share.sendWithSystem(msg, function(){
        outLine('Success');
        console.log('Success');
    }, function(e){
        outLine('Failed: '+JSON.stringify(e));
        console.log('Failed: '+JSON.stringify(e));
    }):shareSystemNativeJS();
}
function shareSystemNativeJS() {
    if(plus.os.name!=='Android'){
        plus.nativeUI.alert('此平台暂不支持系统分享功能!');
        return;
    }
    var intent=new Intent(Intent.ACTION_SEND);
  intent.setType('text/plain');
    intent.putExtra(Intent.EXTRA_SUBJECT,'HelloH5');
    intent.putExtra(Intent.EXTRA_TEXT,sharecontent.value);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    main.startActivity(Intent.createChooser(intent,'系统分享HelloH5'));
}
 
// 调用小程序
function launchMiniProgram(){
    if(!shares['weixin']){
        plus.nativeUI.toast('未配置微信分享模块!');
        return;
    }
    shares['weixin'].launchMiniProgram({
        id: 'gh_33446d7f7a26',        // 小程序原始ID
        type: 0                                        // 正式版
    });
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
        <style type="text/css">
#sharecontent{
    width:80%;
    -webkit-user-select:text;
    border: 1px solid #6C6C6C;
    -webkit-border-radius: 2px;
    border-radius: 2px;
}
#pic{
    width:100px;
    height:100px;
    /*border: 1px dashed #CCCCCC;*/
}
.sharehref{
    width:80%;
    -webkit-user-select:text;
    border: 1px solid #6C6C6C;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    margin-bottom: .5em;
}
        </style>
    </head>
    <body>
        <br/>
        <div class="button" onclick="clicked('share_weixin.html')">微信分享</div>
        <div class="button" onclick="clicked('share_qq.html')">QQ分享</div>
        <div class="button" onclick="clicked('share_sinaweibo.html')">微博分享</div>
        <br/>
        <hr color="#EEE"/>
        <br/>
        <p class="heading">分享内容:</p>
        <textarea id="sharecontent" rows="3">我正在使用HBuilder+HTML5开发移动应用,赶紧跟我一起来体验!</textarea>
        <br/><br/>
        <div class="button" onclick="shareSystem()">系统分享</div>
        <br/>
        <hr color="#EEE"/>
        <br/>
        <p class="heading">需在微信开放平台将应用关联小程序才能正常调用</p>
        <div class="button" onclick="launchMiniProgram()">调用微信小程序</div>
        <div id="outpos"/>
        <div id="output">
Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。
        </div>
    </body>
</html>