【发布时间】:2016-06-17 07:40:47
【问题描述】:
我正在使用 ionic 平台 (ionic io) 实现推送通知,我的推送通知工作正常,现在我必须取出该设备令牌并将其发送到我的服务器。
下面是我的 ap.js 代码:
var push = new Ionic.Push({
"debug": true
});
push.register(function(token) {
console.log("My Device token:",token.token);
push.saveToken(token); // persist the token in the Ionic Platform
});
这是我的登录名
$scope.login = function () {
$http({
method: "post",
url: "http://200.189.253.200:8081/employee-connect/oauth/token",
data: "username="+$scope.username+"&password="+$scope.password+"&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=employeeConnectapp2",
withCredentials: true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.success(function (data){
window.localStorage.setItem("token_type", data.token_type);
window.localStorage.setItem("token", data.access_token);
$state.go('tabsController.home');
})
.error(function(data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}
在成功调用中,我必须通过从控制台获取令牌来发送令牌,但不知道该怎么做。请帮助我。
【问题讨论】:
标签: angularjs ionic-framework push-notification angularjs-scope