Search code examples
titaniumappceleratorappcelerator-titanium

Calling phone with appcelerator


I'm trying on device make calls but device do not nothing...

This is my code, i'm using Appcelerator 4.4.0.201511241829, IOS 9.2

    var dialog = Ti.UI.createAlertDialog({
    cancel: 0,
    buttonNames: ['Cancel', 'Ok'],
    message: "Are you sure?" 

    });

    dialog.addEventListener('click', function(e){

     if (e.index !== e.source.cancel){

        // IF WE ARE BUILDING FOR DEVELOPMENT PURPOSES - TRY CALLING A FAKE NUMBER
        if(ENV_DEV){ 
              Titanium.Platform.openURL('tel:00000000');
        }
        // ELSE IF WE ARE BUILDING PRODUCTION - THEN USE THE LISTED NUMBER
        else if(ENV_PRODUCTION){
             Titanium.Platform.openURL('tel:00000000');
        }
    }  
});

dialog.show();

any help?


Solution

  • Your code for call a number seems correct. I suppose that nothing happen because ENV_DEV and ENV_PRODUCTION variables are not True, and so the two if statements are not satisfy.

    First of all I suggest you to add an else statement for be sure that one one condition is satisfy. You can modify your code like this:

    // IF WE ARE BUILDING FOR DEVELOPMENT PURPOSES - TRY CALLING A FAKE NUMBER
    if(ENV_DEV){ 
        Titanium.Platform.openURL('tel:00000000');
    }
    // ELSE IF WE ARE BUILDING PRODUCTION - THEN USE THE LISTED NUMBER
    else if(ENV_PRODUCTION){
        Titanium.Platform.openURL('tel:00000000');
    }else{
        Titanium.Platform.openURL('tel:00000000');
    }
    

    Secondly you can add a console log like this Ti.API.info("yourMsg") in each statements to check in which if you are.

    I hope this is helpful