简体   繁体   中英

Unable to send push notification with ACS REST API after login

i would like to create a html/javascript form on my website. With the form i woud like to send push notifications too Android and iOS devices.

The login http request works fine:

httpRequest.open('POST','https://api.cloud.appcelerator.com/v1/users/login.json?key=xxxAPKEYxxx&login=xxxEMAILxxx&password=xxxPASSWORDxxx');
    httpRequest.send();     
    httpRequest.onload = function(){             
var data = JSON.parse(this.responseText);
var sessionID = data.meta.session_id;
sendPush();
}

the response: {"meta":{"code":200,"status":"ok","method_name":"loginUser".... So the login is success. But then when i call the sendPush function, i get a response error: the response error: "status":"fail", "code":400, "message":"Failed to authenticate user".

function sendPush(){  
    httpRequest.open('POST','https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=xxxAPPKEYxxx&channel=xxxCHANNELxxx&payload=test');
    httpRequest.send();
    httpRequest.onload = function()
 {
   console.log(this.responseText);
 };
}
function sendPush(){  
    var BASEURL = 'https://api.cloud.appcelerator.com/v1/'
    httpRequest.open('POST', BASEURL + 'push_notification/notify.json?key=APPKE');
    httpRequest.send({
       channel : "xxxCHANNELxxx",
       payload : "test"
    });
    httpRequest.onload = function() {
       console.log(this.responseText);
    };
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM