我正在做的项目,我必须使用离子推送通知。我的推送通知工作正常,我收到通知,并能够发送但问题是收到通知后我必须打开特定页面,这是通知PAGE我也想在通知上设置徽章
这是我的代码
$scope.login = function () {
$http({
method: "post",
url: "http/employee-connect/oauth/token",
data: "username="+$scope.data.username+"&password="+$scope.data.password+"&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=mai",
withCredentials: true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.success(function (data){
//////////////notification Token////////////
var push = new Ionic.Push({
"debug": false; //Can run actions outside the app,
"onNotification": function(notification) {
var payload = notification.payload;
console.log(notification, payload);
},
"onRegister": function(data) {
var PushNotToken=data.token;
console.log("PushNotificationToken="+PushNotToken);
if(PushNotToken!=null) {
$http({
method: "post",
url: baseUrl+"notification-tokens/addToken="+PushNotToken,
withCredentials: true,
headers: {
'Content-Type':'application/json',
'Accept' : 'text/plain',
'Authorization' : ''+window.localStorage.getItem("token_type")+' '+window.localStorage.getItem("token")
}
})
.success(function(data) {
alert("data"+data);
console.log("PushNotToken send successfully. "+PushNotToken);
})
.error(function(data, status) {
console.log("PushNotToken NOT send successfully. "+PushNotToken);
});
}
},
"pluginConfig": {
"ios": {
"badge": true,
"sound": true
},
"android": {
"iconColor": "#343434"
}
}
}) ;
var callback = function(pushToken) {
console.log(pushToken.token);
}
push.register(callback);
我正在注册成功登录设备,然后将令牌发送到我的服务器。
现在我想要
1>当用户点击通知时打开特定页面
2>设置徽章(我必须为Android做这个)这可以设置android中的徽章。