I am trying to add push notifications to my Ionic/Cordova iOS8 app. I already have this working in Android, but am having some difficulty with iOS (go figure). The first thing I did was to install the plugin (https://github.com/phonegap-build/PushPlugin). Then I manually copied the PushNotification.js file into the platforms/ios/www/plugins/www folder. Then I made a separate controller to see if the plugin would work. There is no logging in the XCode console (I do have the console logging plugin installed and working).
.controller('PushCtrl', ['$scope', '$location', '$cordovaPush', 'AuthService', 'UserFactory', function($scope, $location, $cordovaPush, AuthService, UserFactory) {
if (typeof $cordovaPush !== 'undefined' && typeof device !== 'undefined') {
console.log(device.platform);
if (device.platform == 'android' || device.platform == 'Android') {
var config = {
senderID: GCMsenderID
};
} else {
var config = {
"badge": "true",
"sound": "true",
"alert": "true"
}
}
$cordovaPush.register(config).then(function(result) {
console.log("Push Notification Result: " + result);
UserFactory.gcm('register', result.deviceToken);
}, function(err) {
console.log('Unable to device token from Google Cloud Messaging');
});
} else {
console.log('Device is undefined?');
}
}])
All that the gcm method in the UserFactory does is post the value to the server. I made sure the plugin is installed correctly and I followed Apple's tutorials on creating the SSL certificates exactly. I am at a standstill and not sure where to go from here.
Under the cordova push plugin 2.4, the device token is stored in result instead of result.devicetoken for iOS.
Try changing to this and see if it works:
UserFactory.gcm('register', result);