Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS 8.3, nor successhandler nor errorhandler is called when registering #42

Open
stijn-d opened this issue Jun 4, 2015 · 6 comments
Open

Comments

@stijn-d
Copy link

stijn-d commented Jun 4, 2015

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?

@salonitiwari
Copy link

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?

@blumfontein
Copy link

Did you include PushNotification.js in your index.html file?

@playfulThinking
Copy link

I had a similar problem, and have discovered the following:

  • I also switched from the original phonegap plugin, and had not seen this problem before, although I might simply have been lucky
  • I am doing a beta test with TestFlight
  • a user initially installs an earlier version of the app, which used the official plugin, and gives permission for notifications to the popup asking permission
  • no problems...
  • I send out a new beta, which, among other changes, switches to this plugin, which he installs
  • He gets a blank screen; debugging finds that I have code that looks like this:

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));
});
};

  • neither callback occurs, and my app stops as a result, waiting on an unfulfilled promise.
  • also, no popup showed up asking for permission to notify
  • I can reliably reproduce this with the following sequence:
    • install app
    • run, getting blank screen
    • switch to settings app> notifications> my app> allow notifications
    • switch back to my app: it wakes up and works!

Best regards,

Mike

@playfulThinking
Copy link

More info:

  • this is happening on an iPad 3 running ios 8.4
  • it also happens on an iPod Touch 5th generation, running iOS 8.4
  • here's a reliable way to get the blank screen:
    • install app and run
    • at least on the iPod touch, it works
    • disable notifications in settings
    • uninstall the app
    • reinstall the app
    • the app encounters the problem

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.

@playfulThinking
Copy link

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:

  • install and run app with xcode
  • it works fine
  • in settings, turn off notifications for my app
  • have xcode stop the app (note that I don't uninstall it)
  • run the app again with xcode
  • the app misbehaves as before

@playfulThinking
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants