Hi everyone, I’m crossposting here a question I asked on stack overflow, because I think someone here might help me !
Here is the original post : http://stackoverflow.com/q/42654295/7673763
I cannot find why my push notifications do not work.
A small version list :
$ cordova plugin info
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.8.4 "PushPlugin"
$ ionic info
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v5.12.0
Xcode version: Not installed
Here is the code that registers for the push system :
// In config
$ionicCloudProvider.init({
core: {
app_id: "xxxx"
},
push: {
sender_id: "yyyyyy",
pluginConfig: {
ios: {
badge: true,
},
android: {
iconColor: "#343434"
}
}
}
});
// In controller
// Register Push notifications
$ionicPush.register().then(function (t) {
console.log('register successfull', t);
return $ionicPush.saveToken(t, {
ignore_user: true
});
}).then(function (t) {
console.log('Token saved:', t);
alert('Token saved:', t.token);
});
I am debugging with USB android phone, with :
ionic run android
Then I inspect with chrome device inspector to see what’s happening.
Thing is, the ‘register successfull’ appears, with a “correct” token
{
"token": "fWjLt4mOttw:APA91bE4KCycHlu92T6fJTzMFbRFtJdTUrb2u9jv5LTO2yTPD_-sKshbqo93UStwjdJpmLun2tJBCgegaUYnlj9kxxFWFPi9hobZH5W80OnrsPdfxrdYNmp8SYM_SXp-5RiknFrbPl5l",
"app_id": "XXXXXX"
}
But the saveToken method fails with a 404 error. When I replay the request with curl in my shell (right-click>Copy>as curl), I have no errors… Here is the chrome console log :
POST https://api.ionic.io/push/tokens 404 (Not Found)
Ionic Push: Error: Not Found
at q.<anonymous> (app.js:formatted:717)
at q.t.emit (app.js:formatted:9164)
at XMLHttpRequest.n.onreadystatechange (app.js:formatted:9424)
Here is the output from curl (seems correct)
{
"meta": {
"status": 201,
"version": "2.0.0-beta.0",
"request_id": "92487e15-9f2a-416f-c15b-9129e9e10049"
},
"data": {
"token": "fWjLt4mOttw:APA91bE4KCycHlu92T6fJTzMFbRFtJdTUrb2u9jv5LTO2yTPD_-sKshbqo93UStwjdJpmLun2tJBCgegaUYnlj9kxxFWFPi9hobZH5W80OnrsPdfxrdYNmp8SYM_SXp-5RiknFrbPl5l",
"type": "android",
"invalidated": null,
"valid": true,
"created": "2017-03-07T16:43:58.993190+00:00",
"app_id": "f2de99a1",
"id": "c85e1bdbb6b3cf2da8f090ba59df6892"
}
}
Could anyone help me ?
Thanks !