Open Freddycool opened 4 years ago
I have the same problem right now.. Has anyone already found a solution?
The problem is, that the process is called from wrong thread
Wrapping everything to main queue fixes it:
#import <Cordova/CDVPlugin.h>
#import "CFCallNumber.h"
@implementation CFCallNumber
- (void) callNumber:(CDVInvokedUrlCommand*)command {
[self.commandDelegate runInBackground:^{
dispatch_async(dispatch_get_main_queue(), ^{
CDVPluginResult* pluginResult = nil;
NSString* number = [command.arguments objectAtIndex:0];
number = [number stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
if( ! [number hasPrefix:@"tel:"]){
number = [NSString stringWithFormat:@"tel:%@", number];
}
if(![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:number]]) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"NoFeatureCallSupported"];
}
else if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]]) {
// missing phone number
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"CouldNotCallPhoneNumber"];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
}
// return result
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});
}];
}
@end
So we store the patched CFCallNumber.m
file locally and in our CI
we're then replacing the Pods's file with out patched version.
Works just fine.
Hi @davidseek , just tried your solution and it works well. Do you plan to PR this ? Many thanks
Edit:
Actually there is already a fix.
I just installed the latest commit as I was unable to install it with npm install
.
I did it running:
npm install github:rohfosho/CordovaCallNumberPlugin#33ec0d2554266869ad04ccdefb79fbab10614109
@rohfosho - please could you look into merging commit #33ec0d2554266869ad04ccdefb79fbab10614109 into master?
My app depends on it :)
We use angular 7.2, IOS 11. On first click phone call - big delay 10 sec, after that all works fine