0

I'm writing a plugin for Cordova. Within that plugin, all pluginresults are sending correctly and happily. Unfortunately, my problem is after I present a UINavigationController, then dismiss it, PluginResult will not send back to my javascript listener.

I am setting keepCallback, I'm using the same callback right before presenting successfully, but after I call dismissViewController, in the completion handler, the pluginresult does not get sent. There are no console errors, no warnings. The callbackId appears to be valid by all other accounts, other than actually getting to the javascript listener.

I've tried wrapping it inside a dispatch_after block, with a delay ranging from 0.5 seconds to 5 seconds. Nothing is working. Help!!

        UIViewController* tempViewController = [[UIViewController alloc] init];
        self.tempNavController = [[UINavigationController alloc] initWithRootViewController:tempViewController];
        [self.tempNavController setWantsFullScreenLayout:false];
        [self.tempNavController setNavigationBarHidden:true];
        self.tempNavController.modalPresentationStyle = UIModalPresentationPopover;

    [self.viewController presentViewController:self.tempNavController animated:true completion:^{
        ;
    }];

...

[[PayPalHereSDK sharedTransactionManager] processPaymentUsingUIWithPaymentType:paymentOption  completionHandler:^(PPHTransactionResponse *response) {

        [self.viewController dismissViewControllerAnimated:false completion:^{
            [self returnData:response callbackId:self.mDeviceEventListenerCallbackId keepCallback:true];
        }];

    }];

    CDVPluginResult* pluginResult;
    pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:TRANS_EVENT_SWIPE_SUCCESS];
    //This one communicates just fine
    [pluginResult setKeepCallbackAsBool:true];
    [self.commandDelegate sendPluginResult:pluginResult callbackId:self.mDeviceEventListenerCallbackId];
...

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:data];

    dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
    dispatch_after(delay, dispatch_get_main_queue(), ^(void) {
        //This one doesn't get communicated
        [pluginResult setKeepCallbackAsBool:true];
        [self.commandDelegate sendPluginResult:pluginResult callbackId:self.mDeviceEventListenerCallbackId];
    });

....

Alex Gamezo
  • 121
  • 1
  • 8

0 Answers0