Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Telerik Platform Support #11

Open
CurtBaldwin opened this issue Nov 4, 2014 · 8 comments
Open

Telerik Platform Support #11

CurtBaldwin opened this issue Nov 4, 2014 · 8 comments

Comments

@CurtBaldwin
Copy link

I'm creating a phonegap/cordova app using the Telerik Platform. I have it compiling using their build server. (I'm not doing my own builds with Xcode or similar). I have a server to retrieve the token. That's all working fine.

Whenever I run Twilio.Device.setup(token) the app starts. I can't get any error messages out of it or anything. The javascript function executing that command stops executing after that line. I've tried modifying tcPlugin.js like this:

TwilioPlugin.Device.prototype.setup = function (token) {
// Take a token and instantiate a new device object
var error = function (error) {
if (delegate['ondeviceerror']) delegate'ondeviceerror'
if (delegate['onconnectionerror']) delegate'onconnectionerror'
alert(error);
}

    var success = function (callback) {
        var argument = callback['arguments'] || new TwilioPlugin.Connection();
        if (delegate[callback['callback']]) delegate[callback['callback']](argument);
    }

    Cordova.exec(success, error, "TCPlugin", "deviceSetup", [token]);
}

Still nothing coming back. Any ideas to help me troubleshoot this error?

@jefflinwood
Copy link
Owner

Didn't get a chance to look into this - anything you want to share?

@CurtBaldwin
Copy link
Author

Hi Jeff,

First, thanks to you and Steve for your work on this plugin. We use Twilio
a lot and I'm trying to get it working on our Cordova/Phonegap based app to
do voip calling.

I'm an experienced .net/c#/web developer but I'm new to cordova/phonegap.

Yesterday I got a lot further and got past the setup line. I better
understand how things are supposed to work and will be coming back to it
today. I ended up doing the cordova exec statements directly. My code
ended up looking like below. As you can see, I sort of took it out of
being a plugin. Once I did the second cordova connect statement, the app
started crashing. I'm going to put it back more like a plugin and try
again today. My biggest concern is that I'm shipping all of the .a, .h and
.m files off to the telerik platform build. It actually is building an ipa
file. So I think that's good news.

Before I pulled out the cordova.exec statements, things weren't really
working and I was having trouble getting error messages. The try/catches
helped and just doing the execs directly at least got me further.

Not sure why I'm crashing though. I'm getting a generic token using the
app id from Twilio's sample. Do you really just have to do a setup with
the token and then do a connect? Is it that simple?

try
{
//TwilioPlugin.Device.setup(token);
var error = function (error) {
alert(error);
};

        var success = function (callback) {
            var argument = callback['arguments'] || new

TwilioPlugin.Connection();
};
Cordova.exec(success, error, "TCPlugin", "deviceSetup",
[token]);
}
catch(err)
{
alert(err.message);
}

try
{
var error = function (error) {
alert(error);
};

        var success = function (callback) {
            var argument = callback['arguments'] || new

TwilioPlugin.Connection();
};
Cordova.exec(null, null, "TCPlugin", "connect", null);
}
catch (err) {
alert(err.message);
}

On Mon, Nov 3, 2014 at 5:59 PM, Jeff Linwood notifications@github.com
wrote:

Didn't get a chance to look into this - anything you want to share?


Reply to this email directly or view it on GitHub
#11 (comment)
.

@jefflinwood
Copy link
Owner

Hi,

Yes - you absolutely need to create a capability token with your own Twilio credentials - the generic token that might be in some of the Twilio examples won't work - capability tokens are only good for a limited amount of time, which makes them perfect for mobile apps, so you aren't embedding your credentials into an app that someone can pull them out of.

@CurtBaldwin CurtBaldwin reopened this Nov 18, 2014
@CurtBaldwin
Copy link
Author

I have a method to get a token. I've verified the token is working by successfully using Twilio's javascript client in chrome. But using that same technique in phonegap is not working for me. I can't even figure out how to get error messages back. Would definitely appreciate any guidance. I'm happy to share my project. Whatever works.

If anyone is open to sharing a working phonegap sample for making an outgoing call, that would be awesome.

@jefflinwood
Copy link
Owner

Hi, the tokens are compatible between Twilio iOS Client, Android Client, and Javascript client, so that's good.

I'd be happy to take a look at your code - jlinwood at gmail.com if you don't want to share here.

Thanks!

1 similar comment
@jefflinwood
Copy link
Owner

Hi, the tokens are compatible between Twilio iOS Client, Android Client, and Javascript client, so that's good.

I'd be happy to take a look at your code - jlinwood at gmail.com if you don't want to share here.

Thanks!

@peder541
Copy link

peder541 commented Dec 9, 2014

Curt, have you had any success? If not, try passing an object to the connect function like so Cordova.exec(null, null, "TCPlugin", "connect", [{}]);

I'm using the full plugin and got the connect method to work by passing in an object.

@CurtBaldwin
Copy link
Author

Hi Ben,

I had not had success. Your solution worked for me! Thank you very much!

On Tue, Dec 9, 2014 at 8:01 AM, Ben Pedersen notifications@github.com
wrote:

Curt, have you had any success? If not, try passing an object to the
connect function like so Cordova.exec(null, null, "TCPlugin", "connect",
[{}]);

I'm using the full plugin and got the connect method to work by passing in
an object.


Reply to this email directly or view it on GitHub
#11 (comment)
.

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

3 participants