Open stijn-d opened 9 years ago
Hi Team, I am facing similar issue with iPhone 8.0 when using this plugin.
pushNotification = window.plugins.pushNotification is giving an empty object
The plugin got successfully installed. PushPlugin.h and PushPlugin.m are present in Plugins folder. Still Getting error in console: CDVPlugin class CDVPushPlugin (pluginName: PushPlugin) does not exist. ERROR: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml. [CDVCommandQueue executePending] [Line 159] FAILED pluginJSON = ["PushPlugin1657459655","PushPlugin","register",[{"alert":"true","ecb":"onNotificationAPN","sound":"true","badge":"true"}]]
Please help. Am I missing anything?
Did you include PushNotification.js in your index.html file?
I had a similar problem, and have discovered the following:
function initializeIosPush(){ var iosConfig = { "badge": true, "sound": true, "alert": true }; logger.log("in initializePush"); return $cordovaPush.register(iosConfig).then(function(result){ // success - send device token to server, and store for future use logger.log("registration result: " + JSON.stringify(result)); player.deviceToken = {type: 'ios', value: result}; }, function(error){ logger.log("registration error: " + JSON.stringify(error)); }); };
Best regards,
Mike
More info:
Weirdly, if I have notifications enabled when I delete and then reinstall the app, it works again... somehow the previous "notifications disabled" state seems to leak into reinstalls...
In any case, disabled notifications shouldn't result in no callback at all, and no permissions popup on fresh install of the app.
For reference, here's the code that calls the init code:
if(ionic.Platform.isIOS())
// wait for the deviceToken before logging in
initializeIosPush()
.then(login.loginBoth);
I do wait for deviceReady to fire before any of this code runs.
I can now confirm this happens when running the app without installation with TestFlight. I install with xcode and have the exact same problems.
I can also reproduce with this simpler sequence:
Further weirdness.
As an experiment to get around the problem, I switched to this code:
function initializeIosPush(){ var iosConfig = { "badge": true, "sound": true, "alert": true }; logger.log("in initializePush"); var pushPlugin = window.plugins.pushNotification; var deferred = $q.defer(); pushPlugin.areNotificationsEnabled(successHandler, failureHandler); return deferred.promise;
function successHandler(result){ logger.log("notifications are ENABLED xxx"); deferred.resolve(true); return $cordovaPush.register(iosConfig).then(function(result){ // success - send device token to server, and store for future use logger.log("registration result: " + JSON.stringify(result)); player.deviceToken = {type: 'ios', value: result}; }, function(error){ logger.log("registration error: " + JSON.stringify(error)); player.deviceToken = {type: 'none', value: 'none'}; deferred.resolve(true); }); };
function failureHandler(result){ logger.log("notifications are DISABLED xxx"); player.deviceToken = {type: 'none', value: 'none'}; deferred.resolve(true); }; };
(it may not have been apparent from my previous postings: I should have mentioned I've been using ngCordova, except for your areNotificationsEnabled call, which they do not support)
This does prevent the problem, though I don't know why, because here's the weirdness: the success handler is always called, even when notifications are disabled!
Hi Guys,
i used the original phonegap-build, now i've just installed this version. and when calling the register-function no succes or error-handler is being called. My iphone already is setup to allow push-notifications for this application. so I dont get the popup. But On my ipad(ios 8.0.2), still the success-handler is called, and passes the apn-token, on my iphone, nothing is called, so I don't get the token for sending the notifications. Is it something I am doing wrong? Or is this a geniune issue with ios 8.3?