hmd
hmd

Reputation: 970

Integrating Twilio-js in Angular.js?

Can anyone please guide me how do I integrate/require twilio.js file in the my application? I have to do it with angular.js app. I can't require/include it and can't get the Twilio object to call it's methods. I'm really new to it!

By just adding following script tag do not makes me able to use Twilio object:

<script type="text/javascript" src="//media.twiliocdn.com/sdk/js/client/v1.4/twilio.js"></script>

Results:

enter image description here

Update:

As per @philnash help I've resolved the previous error and now this is how my code looks like is:

<script type="text/javascript" src="//media.twiliocdn.com/sdk/js/client/v1.4/twilio.js"></script>
<script>
Twilio.Device.setup(@token, { debug: true, region: "ie1" });
Twilio.Device.ready(function(device) {
    // The device is now ready
    alert("Twilio.Device is now ready for connections");
});
</script>

But I'm getting the below error:

enter image description here

Any help will be appreciated!

Upvotes: 0

Views: 571

Answers (1)

philnash
philnash

Reputation: 73075

Twilio developer evangelist here.

When using the Twilio Client JavaScript, there is no Twilio.setup function.

Instead, you should use Twilio.Device.setup.

Let me know if that helps at all.

Upvotes: 1

Related Questions