Heading Home with the Intel® XDK

Creating a simple personalized app

For a long time, I never understood the popularity of texting. While a phone call is a quick way to verbally connect, and email is for textual information but with no guarantee of when you'll get a response, texting seems to combine the worst of both worlds - a lousy keyboard and no idea when you'll hear back.

I eventually had to give in and try it, if for no other reason than to effectively communicate with my teenager. I have to admit, I quickly discovered it does have a place. It's a way to send quick communications that don't need an immediate response, if any. It's often easier in certain social situations to fire off a text than it would be to open up a laptop, or excuse oneself to go make a call. Unlike my teenager, however, I can't seem to text and walk. (I'm sure it would be a violation of workplace safety standards, at least that's the excuse I'm going with.)

Nevertheless, I do like to let my wife know when I'm heading home, which tends to slow the process of actually heading home, as it takes me a while to compose and type a missive such as:

My dearest wife, like the Monarch Butterfly and the Blue Whale, I'm about to embark on an odyssey that I hope will bring me home in short order (barring traffic, hurricanes and whaling vessels).

As you can imagine, it takes me a while to get going.

Now, while I may be too old to learn to thumb-type like a teenager, I do have one advantage. I know how to create mobile apps. In fact, with the Intel XDK, a lot of simple tasks can be done really easily, so I could create a simple texting app that does just what I need.

In fact, it's so easy, all I really need is one line of code:

intel.xdk.device.sendSMS('Clever message that could only come from me', '5555551234');

This one line of code will send an SMS message, using your default messaging app. In particular, it will drop you into your messaging app with the text and phone number already filled in, and all you need do is hit the send button. Of course, the other important thing to know is exactly where to put this one line of code such that it correctly serves its purpose. Well it turns out there are two useful possibilities.

When you create a new project in the Intel XDK, there are a number of choices, but for our purpose we can choose "Start with a Blank Project". The structure of the blank project that you start with has changed a bit with the latest release. While it used to be that all the code was in the main index.htmlfile , it's been recently rearranged for improved reliability and to be more consistent with best practices. Now when you open a blank project, there are several javascript files provided. There is also a generic header button labeled "Touch Me" in index.html.

If all you want to do is use the provided button, you'll need to modify www/js/app.js, in the function myEventHandler. Simply replace the contents of that function with the line of code above, but be sure to use the phone number you're interested in messaging and you may want to change the text of the message.

If you've done that, you should be able to start the app, hit the button, and then hit a few more things in response to various dialogs and then hit send in your messaging app and you're done. OK, it can still involve a number of button pushes, but at least there's no typing or finding of contacts involved. On my phone, I have to start the app (1) push the button (2) then the phone asks me which app I want to use (3) Just once or Always? (4) and finally send (5).

Of course, we can get that down a bit. If I can get myself to commit to a particular messaging app, we should be down to 3 taps, but we can go one better. Since the sole purpose of this app is to send a single message to a single number, I don't really need the button push at all, I can just immediately send a message when the app starts up. Now, you may not want to do this, in case you occasionally start apps by mistake, but you should be able to avoid actually sending the app in that case, as you still need to hit send in the messaging app. If you do decide to send the missive on startup, you'll need to change where you add the one line of code above.

To modify the startup behavior of the app, find the file www/js/init-app.js and add the line above to the beginning of the function app.initEvents, and now it should immediately go to sending the message when you start the app.

I've already gone on too long here, but you can of course make your app prettier, give it a custom icon, and so on, but if you just want to try an incredibly simple, yet potentially useful app, give it a try.

For more complete information about compiler optimizations, see our Optimization Notice.

3 comments

Top
Jorge F.'s picture

I am new to android ... and also in Intel XDK environment.

Gentlemen supporters, kindly guide me on the questions below:

1-I want to develop an app for android, which from a text box (text area or imput button) the user to inform your contact or a fact or even a complaint, this is sent to a specific e-mail, you see? as a kind of FEEDBACK. It could even be sent also to a specific whatsapp, but do not know what would be the most interesting, quick and efficient resolution of technical view point.

2-I have researched a lot about cord-plugins-email-compose, that is, within the Intel XDK environment; I did several tests and examples collected from the internet, but do not work. On the other hand, outshines in my view the issue of e-mail, domain on android, do not know how this. For I see several apps, same with many such resources, forms, sending data, etc. But I'm having a hard time understanding these things.

3-In a web environment this is all understandable to me. Many years ago, I got to do a few simple things in PHP and Mysql ... as the situation I described above ... made a page in HTML, logging suggestions and invoking a script on the server side PHP that I sent these records to a specific email. I stayed this page in cloud, remember that the (localweb) and localweb server had the resources to support PHP, Mysql. To host this page on the server, I had to create a domain in registro.BR and the service to send form data to an e-mail functioned normally. So I wanted to take this same solution ... the same idea ... ie the web server environment for smartphones environment, android. You see? Finally, develop a simple app that the user could file a claim (form - text area, or INPUT button) and this was sent to a specific e-mail or even a whatsapp. A solution type Push notification.

questions:

1) I have almost given up the cord-plugins-email-compose, however, you can guide me more about this plugin and how to set up properly?
2-Where sets my account email in-cord plug-email-compose?
3) Can I send data from a form (text area) to integrate Intel XDK with PHP? (Ie, because in PHP, I know how to nviar and e-mail)
3) To host app, which server would indicate me?
4) Are there any free or paid server to send the APK and test, ie I could download and test the App on my phone?
5) To host my APP APK or on free or paid server, I would have to necessarily create have a domain? email account?
6) Can demontrar me or send me an APP / APK to record a message, or text, or subject (text area or INPUT button) and internally APP feature to send this message to an e-mail?
7) I enjoyed the Intel XDK environment, but I would indicate another similar tool, given the complexity of dealing with e-mail?

Thanks for the clarification.
Thank you.
Jorge F.

Dale Schouten (Intel)'s picture

The trick is to find a Cordova Plugin that will listen (or allow you to listen) to incoming Whatsapp messages.  When I googled around a bit, I found some that could send Whatsapp messages ' ', but it was unclear if they received them.  One clue here:

http://stackoverflow.com/questions/14540394/listen-to-incoming-whatsapp-messages-notifications

It might be helpful, though it doesn't solve the plugin problem.

Robert N.'s picture

Very useful insight.I as wondering where I would start if i wanted to build an app that lets Whatsapp users vote to a wall ? There are a lot of SMS polling apps but a Whatsapp polling / voting app would very interesting.Especially in developing countries where its use is very high.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.