Coder Social home page Coder Social logo

Slow first run about cordovacallnumberplugin HOT 4 OPEN

Freddycool avatar Freddycool commented on August 16, 2024 4
Slow first run

from cordovacallnumberplugin.

Comments (4)

idroxid avatar idroxid commented on August 16, 2024 2

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

from cordovacallnumberplugin.

brunodelsing avatar brunodelsing commented on August 16, 2024

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

from cordovacallnumberplugin.

davidseek avatar davidseek commented on August 16, 2024

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.

from cordovacallnumberplugin.

nicholaspearson avatar nicholaspearson commented on August 16, 2024

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

My app depends on it :)

from cordovacallnumberplugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.