acmPush module example demo

Thank you for sharing with forum moderator Ma Haochuan.

Module Description: Alibaba Cloud Mobile Push is a mobile intelligent push service based on big data, which helps App integrate mobile push function quickly, while achieving efficient, accurate and real-time mobile push, greatly reducing the development cost. To enable developers to maintain the most effective connection with users, thereby improving user activity and application retention.
EMAS Operational Diagram: Create, here get the value of the configuration item


Configure ios push certificate:

Individual device id needs to be filled in in development environment

Message notification: You need to open the message to listen for addMessageListener

Records:

<head>

<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>Hello APP</title>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<style>
    label {
        margin: 10px;
        font-size: 24px;
    }

    ul {
        margin-bottom: 10px;
    }

    ul li {
        margin: 5px 10px;
        padding: 5px;
        color: #000;
        word-wrap: break-word;
    }

    button {
        font-size: 18px;
        display: block;
        padding: 10px;
    }

</style>
</head>

<body>

< button > statistics App startup information (Android) < button >
< button > add message listener </button >
<button>Remove message listener</button>
Get device unique identifier </button>
<button>Open the push channel (android)</button>
< button > close the Android </button >
< button > query channel status </button >
< button > binding label </button >
<button>Label query for this device </button>
< button > device add alias </button >
< button > Set Notification Voice </button >
< button > Set the notification bar icon </button >
< button > Set the interruption-free period </button >
< button > turn off interruption-free </button >
<button>Delete all notifications </button>
<button> Synchronization Angle Scale to Server </button>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">

var acmPush;
apiready = function() {
    acmPush = api.require('acmPush');
};

function getDeviceId() {
    acmPush.getDeviceId({}, function(ret, err) {
        console.log(JSON.stringify(ret));
    });
}

function addMessageListener() {
    acmPush.addMessageListener({
        listenerName: 'name',
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function onAppStart() {
    acmPush.onAppStart({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function turnOnPushChannel() {
    acmPush.turnOnPushChannel({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function turnOffPushChannel() {
    acmPush.turnOffPushChannel({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function checkPushChannelStatus() {
    acmPush.checkPushChannelStatus({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function bindTag() {
    acmPush.bindTag({
        target: 1,
        tags: ["Google", "Runoob", "Taobao"],
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function listTags() {
    acmPush.listTags({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function addAlias() {
    acmPush.addAlias({
        alias: 'Alias 1',
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function setNotificationSound() {
    acmPush.setNotificationSound({
        soundPath: 'widget://res/sound.mp3',
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function setNotificationLargeIcon() {
    acmPush.setNotificationLargeIcon({
        iconPath: 'widget://res/QQ.png',
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function setDoNotDisturb() {
    acmPush.setDoNotDisturb({
        startHour: 0,
        startMinute: 02,
        endHour: 1,
        endMinute: 02
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function closeDoNotDisturbMode() {
    acmPush.closeDoNotDisturbMode({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

function clearNotifications() {
    acmPush.clearNotifications({}, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}
function syncBadgeNum() {
    acmPush.syncBadgeNum({
        num: 1,
    }, function(ret, err) {
        alert(JSON.stringify(ret));
    });
}

</script>

</html>

Tags: iOS JSON Mobile Android Javascript

Posted on Tue, 08 Oct 2019 22:09:19 -0700 by mzfp2