urbanairship / ios-phonegap-plugin

This repo is deprecated. Please see: https://github.com/urbanairship/phonegap-ua-push
https://github.com/urbanairship/phonegap-ua-push
68 stars 11 forks source link

RegisterAPN error callback never registered/called #7

Closed jonathantrevor closed 12 years ago

jonathantrevor commented 12 years ago

Im not getting the error callback called when a register failure occurs:

if (argc > 1 && [[arguments objectAtIndex:1] length] > 0) {
    NSLog(@"registererror");
    self.registerErrorCallback = [arguments objectAtIndex:1];
}

The logging statement never gets called, so I assume there's some issue with passing the js callback through.

Here's the register call from the JS side:

    window.plugins.pushNotification.register(
        successAPNCallback,
        errorAPNCallback,
        [ {
         alert:true,
         badge:true,
         sound:true
        }]
    );

Success callback works just fine.

jonathantrevor commented 12 years ago

Finally worked it out. The git code seems to span 2 types of callback system in Phonegap and doesn't work perfectly with either.

The argc line is an old-style (I think/hope) way of registering callbacks in Phonegap, as the callbackId scheme contains BOTH the success AND the failure callback references.

Therefore to call the error callback when an error occurs we need to find the error handler and invoke it:

Not sure how to plug the error into the result dictionary but that isnt critical.