Axway AMPLIFY Blogs

The Leading Resource for All THings Mobile & Data Integration

Twilio SMS Messaging — Axway Titanium Cross-Platform Library

0 Flares 0 Flares ×

This guest post was authored by Adam Armstrong. Adam has been using Titanium since 2010 and is an Appcelerator Titan. He is the Manager of Mobile Technology at AmWINS Group and does freelance work via http://implicitli.com. You can follow him on Twitter at @adamtarmstrong.

I have integrated Twilio SMS Messaging for various clients over the past few years and decided it was time to wrap this up into my own library to ease portability.

For this library — I took a very simplistic approach. I added SMS Messaging and no SDK’s or additional libraries; just a basic common.js module.

1*XkY05wvmneueneeJliL9NQ

Setup Twilio Account and API Key

  1. Create a free Twilio Account at https://www.twilio.com/
  2. Create an API Key at https://www.twilio.com/console/video/dev-tools/api-keys

IMPORTANT: Make note of your API Secret. After you complete the setup, the API Key can no longer be retrieved.

Download Library

Copy the /lib/ti.twilio.js file into your Axway Titanium Project under /app/lib/

https://github.com/adamtarmstrong/ti.twilio

Add Module and Initialize

  • AccountSID, APISID, & APISecret = All {strings} from your Twilio Account
  • timeout = {integer} to define API timeout in milliseconds
  • FROM_PhoneNumber = {string} in E.164 format of phone # to send message FROM (ie. +15005550006′)

NOTE: FROM_PhoneNumber passed in must match the API Key Environment (more details in github repo)

var twilioClient = require('ti.twilio');
twilioClient.init('AccountSID', 'APISID', 'APISecret', 'FROM_PhoneNumber', timeout);

Send SMS Message

  • Message = {string} message to send to user
  • TO_PhoneNumber = {string} in E.164 format of client phone # to send message TO (ie. +146921439389′)
  • successCallback = {function} to execute upon success
  • failureCallback = {function} to execute upon failure
twilioClient.sendSMS(Message, TO_PhoneNumber, successCallback, failureCallback);

That’s it!

This is a basic SMS Message – I plan to expand the methods over time. Code contributions are greatly appreciated!

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×
computer and tablet showing Appcelerator software
Start free, grow from there.
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×