Reputation: 4724
I am using a push notification plugin in my cordova application. I was able to get the notification for Android using GCM and it was pretty easy. Now iOS which is a big pain for me since Sunday, almost 4 days now. I will share the things that i have done so far. Please help me to get the notification working on iOS devices too.
According to the plugin, on the application side my java script looks like this
myApp.controller('Register', function ($scope) {
$scope.regGCM = function () {
document.addEventListener('deviceready', onDeviceReady, false);
}
function onDeviceReady() {
var push = PushNotification.init({
"android": {
"senderID": "41502493944",
"sound": "true",
"vibrate": "true",
},
"ios": {
"alert": "true",
"badge": "true",
"sound": "true",
},
"windows": {}
});
push.on('registration', function (data) {
var deviceid = data.registrationId;
alert(deviceid);
});
push.on('notification', function (data) {
console.log("notification");
});
push.on('error', function (e) {
console.log("push error");
});
}
});
When regGCM()
triggers iOS device asking for permission to allow the push notification for my application and it returns a token
.
Then to test the push notification online i used this site which requires our token
and .pem
file.
To create a .pem
file i did the following things.
1) Created a p.notification certificate from here.
2) Installed that in mac keychain.
3) Exported installed certificate as pushcert.p12
file.
4) Executing this command (openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts
) in terminal i got the pushcert.pem
file.
That online testing site says message has sent but i never got the notification to my iOS device. I am new to push notification and don't know the correct steps, may be missing something. Is there anyone how figured iOS p.notification in cordova. I don't mind the way of doing it whether it is using GCM or native APNs.
Any help would be much appreciated.
Upvotes: 1
Views: 337
Reputation: 21
I checked with mentioned website : http://www.pushwatch.com/apns/. It's working proper.
You are not getting push notification due to improper push certificate.
If you are not getting device token,then you can assume that certificate is not created properly.
Regards...
-Harsh Shah
Upvotes: 1