基于HTTP协议开发指导

POST /oauth2/v2/token HTTP/1.1
Host: Login.cloud.huawei.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_secret=61014&client_id=test61014bba8df90acb8eb1s0a2081f
消息请求样例:
Content-Type: application/json;charset=utf-8
{ 'validate_only': false, 'message': { 'notification': { 'title': 'Big News', 'body': 'This is a Big News!' }, 'android': { 'collapse_key': -1, 'priority': 'NORMAL', 'ttl': '1448s', 'bi_tag': 'Trump', 'fast_app_target': 1, 'notification': { 'title': 'Noti in Noti title', 'body': 'Noti in Noti body', 'icon': 'https://res.vmallres.com/pimages//common/config/logo/SXppnESYv4K11DBxDFc2.png', 'color': '#AACCDD', 'sound': 'http://att.chinauui.com/day_120606/20120606_7fcf2235b44f1eab0b4dadtAkAGMTBHK.mp3', 'tag': 'tagBoom', 'click_action': { 'type': 1, 'intent': '#Intent;compo=com.rvr/.Activity;S.W=U;end' }, 'body_loc_key': 'M.String.body', 'body_loc_args': [ 'Boy', 'Dog' ], 'title_loc_key': 'M.String.title', 'title_loc_args': [ 'Girl', 'Cat' ], 'channel_id': 'RingRing', 'notify_summary': 'Some Summary', 'style': 1, 'big_title': 'Big Boom Title', 'big_body': 'Big Boom Body', 'big_picture': 'https://developer-portalres-drcn.dbankcdn.com/system/modules/org.opencms.portal.template.core/resources/images/icon_Promotion.png', 'auto_clear': '86400000', 'notify_id': 486, 'group': 'Espace', 'badge': { 'num': 99, 'class': 'Classic' } } }, 'token': [ 'AAWWHI94sgUR2RU5_P1ZptUiwLq7W8XWJO2LxaAPuXw4_HOJFXnBlN-q5_3bwlxVW_SHeDPx_s5bWW-9DjtWZsvcm9CwXe1FHJg0u-D2pcQPcb3sTxDTJeiwEb9WBPl_9w' ] } }
回执消息样例:
Content-type: application/json
Content-Length: 134
Host: 100.100.147.14:8580
Connection: Keep-Alive
User-Agent: Apache-HttpAsyncClient/4.1.2 (Java/1.8.0_101)
X-HUAWEI-CALLBACK-ID: timestamp=1563105451261;nonce= a07bfa17-6d82-4b53-a9a2-07cfef5ceef1;value=E4YeOsnMtHZ6592U8B9S37238E+Hwtjfrmpf8AQXF+c=
{ 'statuses': [ { 'biTag': '131415', 'appid': '0000000013', 'token': '14889646529623230000000013000001', 'status': 0, 'timestamp': 1489993883189, 'requestId': '1234567890' }, { 'biTag': '131415', 'appid': '0000000013', 'token': '14889646529623230000000113000001', 'status': 2, 'timestamp': 1489993888189, 'requestId': '1234567890' } ] }
基于XMPP协议开发指导

1、开发者服务器接入HUAWEI Push XMPP服务器,建立XMPP连接。
String serverIp = 'push-xmpp.cloud.huawei.com'; //华为Push XMPP服务器接入域名
int serverPort = 5236; //华为Push XMPP服务器开放端口号
ConnectionConfiguration config = new ConnectionConfiguration(serverIp, serverPort);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
Connection connection = new XMPPConnection(config);
connection.connect();
2、开发者服务器接入HUAWEI Push XMPP服务器登录认证。
String usrName = '61014@push-xmpp.cloud.huawei.com'; //用户名为开发者APPID@push-xmpp.cloud.huawei.com格式
String password = 'CF02+Urle/P9d+Jsp1dHmaO8rNymwBkbHptH4Rja5nW4TmA==';//密码使用开发者申请的Access Token
connection.login(usrName, password);
3、开发者基于XMPP连接发送Push消息,详细请参考XMPP消息下发API章节。
Message message = new Message(); //构造消息体,开发者自己设置消息体内容
connection.sendPacket(message); //基于XMPP连接发送Push消息
回执请求报文格式:
<message id=''>
<hcm >
{
'category':'com.example.yourapp',
'data':
{
'message_status':'MESSAGE_SENT_TO_DEVICE',
'original_message_id':'m-1366082849205'
'device_registration_id':'REGISTRATION_ID'
},
'message_id':'dr2:m-1366082849205',
'message_type':'receipt',
'from':'push-xmpp.cloud.huawei.com'
}
</hcm>
</message>





































苏公安网备 32011402010933号