我正在为Cordova写一个插件。在该插件中,所有插件都正确且快乐地发送。不幸的是,我的问题是在我呈现UINavigationController之后,然后解雇它,PluginResult将不会发送回我的javascript监听器。
我正在设置keepCallback,我在成功呈现之前使用相同的回调,但在调用dismissViewController后,在完成处理程序中,pluginresult不会被发送。没有控制台错误,没有警告。除了实际访问javascript侦听器之外,callbackId似乎对所有其他帐户都有效。
我尝试将它包装在dispatch_after块中,延迟范围为0.5秒到5秒。什么都行不通。帮助!
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];
});
...