Skip to content
This repository has been archived by the owner on Oct 22, 2022. It is now read-only.

Slow first run #78

Open
Freddycool opened this issue Sep 23, 2019 · 4 comments
Open

Slow first run #78

Freddycool opened this issue Sep 23, 2019 · 4 comments

Comments

@Freddycool
Copy link

We use angular 7.2, IOS 11. On first click phone call - big delay 10 sec, after that all works fine

@brunodelsing
Copy link

I have the same problem right now..
Has anyone already found a solution?

@davidseek
Copy link

davidseek commented Feb 14, 2020

The problem is, that the process is called from wrong thread

Screen Shot 2020-02-14 at 12 50 41 PM

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.

@idroxid
Copy link

idroxid commented Jul 22, 2020

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

@nicholaspearson
Copy link

@rohfosho - please could you look into merging commit #33ec0d2554266869ad04ccdefb79fbab10614109 into master?

My app depends on it :)

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

No branches or pull requests

5 participants