|
txPush模块(移动推送 TPNS)demo示例
[复制链接]
移动推送 TPNS (Tencent Push Notification Service) 为您提供稳定、快速、高抵达的 App 推送服务。其接入方便快捷,拥有业内领先的技术实力,稳定可靠的消息推送通道,特有的智能推送通道策略,能有效提升消息抵达率;系统每分钟可容纳1800万推送消息,消息能秒级到达(支撑王者荣耀等腾讯内应用推送工具);此外,其具备精准用户标签能力,有效助力 App 的精细化运营。
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Develop</title>
- <meta charset="utf-8">
- <meta name="viewport"
- content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <style type="text/css">
- html,
- body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240, 240, 240, 1.0);
- border-color: rgba(220, 220, 220, 1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240, 240, 240, 0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <br />
- <a class="button" tapmode="active" onclick="addNotifaction()">添加推送事件</a>
- <a class="button" tapmode="active" onclick="removeNotifaction()">移除推送事件</a>
- <a class="button" tapmode="active" onclick="registerPush()">注册推送</a>
- <a class="button" tapmode="active" onclick="isRegisterPush()">是否注册推送</a>
- <a class="button" tapmode="active" onclick="getToken()">获取Token</a>
- <a class="button" tapmode="active" onclick="unregisterPush()">反注册推送</a>
- <br />
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var demo = null;
- apiready = function () {
- demo = api.require('txPush');
- if (!demo) {
- alert("请添加模块后编译");
- return;
- }
- }
- function addNotifaction() {
- demo.addNotifaction(function (ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- function removeNotifaction() {
- demo.removeNotifaction(function (ret, err) {
- //alert(JSON.stringify(ret) +" "+JSON.stringify(err));
- });
- }
- function registerPush() {
- demo.registerPush({
- AccessId_Android: 1500005758,
- AccessKey_Android: 'ASDX2TBIOG5G',
- AccessId_iOS: 1600005759,
- AccessKey_iOS: 'IKDH5JF7DTKE',
- }, function (ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- function getToken() {
- var ret = demo.getToken();
- alert(JSON.stringify(ret));
- }
- function isRegisterPush() {
- demo.isRegisterPush(function (ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- function unregisterPush() {
- demo.unregisterPush(function (ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- </script>
- </html>
复制代码
|
|