Countism

Countism App Icon

Countism is a mobile app idea that I have been working on and thinking about for a long time. Even though I have been thinking of the idea for a while and even did some initial work, I did not plan to actually build and release the app – that was always a question that was up in air. My initial work was really just experimental to see if it was something I could build easily enough to make it worth the effort, and to see if my idea would be viable in app form.

Continue reading

Titanium Proxy Objects With JavaScript Call and Apply

Sometimes language and platform abstractions bite you. They can seem pretty straightforward and “just like the real thing”, but sometimes they have odd behaviors that don’t quite work the way you expect.

Dynamic method invocation with .call() and .apply()

The .call() and .apply() functions are something you will use a lot if your code involves a lot of dynamic arguments, such as building an array of arguments that then need to be mapped to actual ordered function arguments in a function or method call.

Since Titanium runs native JavaScript with the V8 engine bundled in your app, you will naturally find yourself attempting things like this:

var args = [sql].concat(params);
var db = Ti.Database.open('dbname');
var rs = db.execute.apply(db, args);

But if you run that, and you will be presented with the head-scratching error:

invalid method 'execute:'

Although the error is pretty confusing – you know there is a method named execute on the db object – there actually is a good explanation for this behavior.

Titanium Proxy Objects

What intiutively seems to you like a normal JavaScript variable here – db – is actually a proxy object created and returned by Titanium with the Ti.Database.open call. Titanium also returns proxy objects for pretty much every other component that has a native counterpart they are bridging over to behind the scenes. This black magic is fundamental to how Titanium works internally.

The Solution

Although the main Titanium proxy object explanation suggests creating a wrapper object for the method call, that’s actually not necessary at all, and creates a lot of extra work, as well as many additional lines of code.

The best solution is to use a bit of JavaScript meta programming and call the apply method directly from the Function prototype:

var args = [sql].concat(params);
var db = Ti.Database.open('dbname');
var rs = Function.prototype.apply.call(db.execute, db, args);

This is a nice one-liner that achieves the same end result, is much easier to undertand, and does not require a wrapper object or another layer of indirection to achieve.

Pulling My Apps From The App Store: Lessons Learned

itunesconnect-unpublished-apps

Last night, I decided to pull my two iOS and Android apps SEMTab SEO Pro and my very first app, AutoRidge Lite from the App Store and Google Play. It was a difficult decision to make, because they were my first two apps, and I now have no published mobile apps to show potential freelance clients when they ask for app examples. This does limit my options, but now is a great time to make this move since I just started a full-time long-term contract and won’t be actively looking for extra work right now.

Showcasing Quality

With the recent shutdown of my company, I feel like I’m writing a new chapter in my life. Having any app in the app store just to say I have one is no longer enough. The bar is higher now. I want a high-quality, well-rated app that people genuinely like and want to use. I want something I can really be proud of. It doesn’t have to be complicated or difficult, or even do anything fancy. It just has to look good, and do one thing well — and not crash randomly. Difficult task, I know.

What A Bad App Looks Like

To provide an example of the kind of results a bad quality app will give you, look no further than my own app – my only paid app – one I just pulled from the stores – SEMTab SEO Pro. This app was ill-conceived and hastily crafted. The UI wasn’t thought out very well, and neither was the stability of the source data. The code I used to fetch Google’s PR ranking was frequently wrong (I apparently used the wrong black magic incantation to summon the accurate result), and link counts from Facebook and Twitter were different than what were reported by other (more accurate) tools and by the platforms themselves (turns out the API I used was way outdated).

Ratings

On Google Play, SEMTab had an abysmal rating of 1.6. This is primarily due to the app crashing or just plain not working on a few Android devices that I was not able to test on, or were not actually supported (like the “Rubbish” review you see for it not working on the Galaxy Tab – one of the first Android tablets that liked to pretend it could run normal Android apps just fine).

semtab-googleplay-ratings

On the App Store, the app was a lot more stable, but still got a bad rating for its terrible accuracy.

semtab-appstore-ratings

Revenue

The app was $1.99, and was on sale for $0.99 for an extended period of time to try and boost sales. Obviously, this strategy doesn’t work if your app sucks and has a bunch of bad ratings.

Google Play Revenue

semtab-googleplay-revenue

App Store Revenue

itunesconnect-proceeds-2009-2014

A whopping $127.19 from Google and $83.01 from Apple, for a grand total of $210.20. In 4 years. Ouch. Totally not worth the (admittedly small) effort I put into it.

Why I Pulled SEMTab SEO Pro

The reasons here are prety obvious, right? At this point, the ratings and performance of this app are so bad that I don’t even want it in my portfolio. I didn’t even want people to know I made this app, and was a bit embarrased to mention it whenever the “what apps have you made?” question came up, fearful people would see the terrible rating read all the horrible reviews. Good riddance. (And if you’re wondering why I am publicly sharing all this now, it’s for accountability – I never want to make an app this bad again.)

What a Mediocre App Looks Like

I am definitely more proud (or, at least, not embarrased) by my first app – Autoridge. I was a lot more torn about taking down Autoridge than I was about SEMTab. The reviews of Autoridge basically boil down to this:

  • The people who used the app and found relevant data for their vehicle’s year/make/model loved it. It provided huge value for them.
  • The people who could not find their specific vehicle’s year/make/model, or didn’t find any (or very few) relevant parts for their vehicle mostly trashed it as incomplete, inaccurate or unreliable.

Poor Early Titanium Android Support

And as in the case of SEMTab, there were also quite a few Android users that the app didn’t work for at all (freezing or crashing). I mostly attribute this to the very poor early Appcelerator Titanium Android support. Both these apps were developed and released at least 3 years ago on Titanium versions 1.5.x – 1.7.x, and a lot has changed for the better since those dark ages with Titanium (we have have an MVC framework called Alloy, and Titanium is at 3.2.x). From my experience with Alloy, I am positive that updated versions of these apps would elimate all the problems on Android.

That said, it’s pretty disharenting when you develop an Android app with an intermediate platform like Titanium, test it locally with your own Android device and emulator working perfectly, and then release it to a tsunami of 1-star reviews and reports of random freezes and crashes on various Android devices that you can’t do anything to fix.

Ratings

On Google Play, Autoridge Lite had a very average rating of 3.1. I am actually suprised it was this high with the number of ratings reporting freezes and crashes, but like I said, the number of people who it did work for generally loved it. You can see this wide rating distribution reflected in the data. This saddens me a bit, because the rating could have easily been 4+ in Google Play if it worked consistently across all Android devices.

autoridge-googleplay-ratings

The App Store rating was pretty much the same story, with all the negative reviews questioning data completeness and accuracy:

autoridge-appstore-ratingstars

Distribution

The uptake of Autoridge Lite surprised me from the start. It definitely seems like something people were ready to embrace if the data was more accurate, complete, and up-to-date. I think overall, people really like the idea of using an app instead of flipping through a greasy old parts book at the auto part store.

App Store Distribution Units

itunesconnect-units-2009-2014

Google Play Installs

autoridge-googleplay-unitsautoridge-googleplay-activeinstalls

According to Google, there are still 1,584 devices with Autoridge Lite installed. Definitely far better than SEMTab SEO Pro that had only 12 active installs. A lot of people still like this app.

Why I Pulled Autoridge Lite

The decision to pull Autoridge from the App Store and Google Play was much harder than with SEMTab, but ultimately, it came down to an issue of time, energy, and focus:

  • Autoridge Lite has a webservice backend that I also built and maintain, and this costs time and money.
  • The vehicle data has a low degree of accuracy with no automatic error correction, and would take a significant re-investment of time and energy to correct. I would have to research new sources of auto part information and build web scrapers/parsers for each of them, as well as implement better processes for checking for updates and invalidating bad data.
  • I want to completely re-code the app, and have wanted to for a while. So doing this plus all the webservice updates too would probably take longer than the original 2 weeks the entire project took initially. And since I can’t update the app only without fixing the data accuracy issue, I have to consider the whole picture.

In short – it would take too long to re-build the right way, and I don’t currently see it as worth the effort considering I haven’t made any money from it (and don’t see any path to make significant money from it ever as a one-man show).

Conclusion

Although this choice was tough, and arguably should have happened a long time ago, I am happy to be doing it now. The first step towards finding something that works is identifying and eliminating the stuff that doesn’t. The worst thing that can happen is to split your time, energy, and focus across so many projects that you do them all badly. This is exactly what I feel I have done. I want to be able to focus on my next project, I want it to be high-quality, and I want it to have a clear revenue path. This whole “making money with software” path is not an easy one, so I want to give myself the best chance possible by concentrating on the next big thing, and making a better product than I’ve ever made before. That’s what this move is all about.

Excessive Data Usage with iPhone 4S / iOS5

Got a new iPhone 4S or recently upgraded your iPhone 4 or 3GS to IOS5 and noticing unusually high cellular data usage? Are you close to exceeding your data usage limit when you never have before? Have you already exceeded it? You are not alone.

My wife recently traded in her old iPhone 3G for a shiny new iPhone 4S, and within 10 days had exceeded her 200MB AT&T data plan limit when she has never exceeded it before. So what gives? It’s a new phone, and Siri does transmit voice data back to Apple’s servers, but could that really have caused the usage? Continue reading

How to add Photos to the iPhone Simulator

Building an app that needs to access the photo library but don’t have any photos in the iPhone simulator? No problem. Follow these simple steps to import photos into the iPhone Simulator:

  1. Open the iPhone Simulator
  2. Browse to the photo you want to put into the simulator (Finder or web browser)
  3. Click and drag the photo over the simulator window. A green "plus" icon should appear under your cursor with the simulator frame highlighted. Drop the photo.
  4. Mobile Safari should open on the simulator to the location of the image you just dragged and dropped over it
  5. Note that if the image you dropped is linked in a webpage, it will open the link instead of the image URL.
  6. Click the mouse down over the image and hold it until a popup window appears.
  7. Click "Save Image"

The photo will now reside in the "Saved Photos" album on the iPhone Simulator. Rince and repeat as many times as you need to get all your photos in the album.

Easier Titanium XHR and AJAX Requests

One question I see a lot on the Appcelerator Titanium Developer Q&A is how to perform AJAX requests and/or work with APIs, etc. There is a built-in way to do this with the Ti.Network.HTTPClient module that is pretty easy, but it does have a few drawbacks and “gotchas”, like executing the “success” event for ANY returned status code – even 500 errors. Since working with APIs is so common with mobile apps, I made a wrapper function modeled after jQuery’s $.ajax method that I use in all my apps. It shortens the syntax quite a bit and is much more familiar to those who are used to using jQuery.

The usage looks like this:

// Geocode input text location
app.utils.ajax({
     url: 'http://maps.googleapis.com/maps/api/geocode/json?address=' + txtLocation.value +'&region=us&sensor=true',
     method: 'get',
     success: function(xhr) {
         var data = JSON.parse(xhr.responseText);
         Ti.API.info(data);

         if("OK" == data.status) {
             var res = data.results[0];
             if(res) {
                 alert("Location: " + res.geometry.location.lat + ', ' + res.geometry.location.lng);
             }
             // Do something with coordinates
         } else {
             Ti.UI.createAlertDialog({
                 title: 'Geocode Error',
                 message: 'Unable to geocode location input'
             }).show();
         }
     },
     error: function(xhr) {
         Ti.UI.createAlertDialog({
             title: 'Geocode Error',
             message: 'No location matches found. Please try something else.'
         }).show();
     }
});

And the actual code for the utility function:

/**  * Application Utilities and Helper Methods  **/
(function(_app) {
     _app.utils = {};

     // AJAX method that mimmicks jQuery's
     _app.utils.ajax = function(_props) {
          // Merge with default props
         var o = _app.combine({
             method: 'GET',
             url: null,
             data: false,
             contentType: 'application/json',

             // Ti API Options
             async: true,
             autoEncodeUrl: true,

             // Callbacks
             success: null,
             error: null,
             beforeSend: null,
             complete: null
         }, _props);

         Ti.API.info("XHR " + o.method + ": \n'" + o.url + "'...");
         var xhr = Ti.Network.createHTTPClient({
             autoEncodeUrl: o.autoEncodeUrl,
             async: o.async
         });

         // URL
         xhr.open(o.method, o.url);

         // Request header
         xhr.setRequestHeader('Content-Type', o.contentType);

         if(o.beforeSend) {
             o.beforeSend(xhr);
         }

         // Errors
         xhr.setTimeout(10000);
         xhr.onerror = function() {
             Ti.API.info('XHR "onerror" ['+this.status+']: '+this.responseText+'');
             if(null !== o.error) {
                 return o.error(this);
             }
         };

         // Success
         xhr.onload = function() {
             // Log
             Ti.API.info('XHR "onload" ['+this.status+']: '+this.responseText+'');

             // Success = 1xx or 2xx (3xx = redirect)
             if(this.status < 400) {
                 try {
                     if(null !== o.success) {
                         return o.success(this);
                     }
                 } catch(e) {
                     Ti.API.info('XHR success function threw Exception: ' + e + '');
                     return;
                 }

             // Error = 4xx or 5xx
             } else {
                 Ti.API.info('XHR error ['+this.status+']: '+this.responseText+'');
                 if(null !== o.error) {
                     return o.error(this);
                 }
             }
         };

         // Send
         if(o.data) {
             Ti.API.info(o.data);
             xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
             xhr.send(o.data);
         } else {
             xhr.send();
         }

         // Completed
         if(null !== o.complete) {
             return o.complete(this);
         }
     };

     // And it does depend on this code below to combine object properties:

     // Extend an object with the properties from another
     // (thanks Dojo - http://docs.dojocampus.org/dojo/mixin)
     var empty = {};
     function mixin(/*Object*/ target, /*Object*/ source){
         var name, s, i;
         for(name in source){
             s = source[name];
             if(!(name in target) || (target[name] !== s && (!(name in empty) || empty[name] !== s))){
                 target[name] = s;
             }
         }
         return target; // Object
     };
     _app.mixin = function(/*Object*/ obj, /*Object...*/ props){
         if(!obj){ obj = {}; }
         for(var i=1, l=arguments.length; i<l; i++){
             mixin(obj, arguments[i]);
         }         return obj; // Object
     };

     // Create a new object, combining the properties of the passed objects with the last arguments having
     // priority over the first ones
     _app.combine = function(/*Object*/ obj, /*Object...*/ props) {
         var newObj = {};
         for(var i=0, l=arguments.length; i<l; i++){
             mixin(newObj, arguments[i]);
         }
         return newObj;
     };
})(app);

The particular organization of this utilities file assumes that your app structure follows the organization model shown in the Tweetanium example app (using the ‘app’ namespace within a single window context), but is easy to adapt if you are not.

php|tek 2011

php|tek 2011 Speaker Chicago – May 24-27 php|tek in Chicago was fun as always. It is the best PHP conference I have ever been to, which makes sense, given that it is focused solely on PHP and surrounding technologies. The best thing about the conference is the community feeling in general. You get a real sense that everyone there really cares about PHP and is heavily invested in it, which is good for moving the whole language and ecosystem forward.

I myself gave two talks – one about Stackbox CMS, a new CMS project I have been working on, and one about Apppcelerator Titanium Mobile since I have been working with it a lot lately. The presentations are embedded below.

Continue reading

Android+iPhone SEO App

I just released a new iPhone SEO app and Android SEO app called SEMTab SEO Pro. The basic idea is to keep a list of domains saved, and check SEO/SEM stats like Google PageRank (PR), backlinks, Alexa rank, etc. and Social share information from Twitter, Facebook, and Delicious. more

ss1-listss2-webss3-social1

 

The first two pictures are of the iPhone app, and the last one is of the Android app. SEMTab SEO Pro was built with  Titanium using all native cross-platform UI controls, so it builds both the iPhone and Android app from a single codebase and a single development effort.

The nice thing about SEMTab is that it makes extensive use of Titanium’s event system to fire off simultaneous asynchronous HTTP requests to the various web services and APIs to fetch data about the current domain you are checking. This prevents the application from locking up while fetching rank or share information, and it prevents the HTTP requests from stacking up in a queue and waiting for the ones in front of it to finish. The end result is a pretty slick & simple SEO app that gets the results you want quickly, without feeling sluggish or unresponsive.

Check out SEMTab SEO Pro in the App Store or the Android Market when you get the chance — and don’t forget to leave some feedback with a rating.

Listing Aliases Inside an Android Keystore File With Keytool

If you lose or forget your Android keystore file alias that is used to build APK files for distribution (like I did when trying to package Autoridge Lite for the Android Market), here is a quick and easy way to see them:

  1. Open a Terminal Window, Run This Command:

    keytool -list -keystore /location/of/your/com.example.keystore

    Make sure "keytool" is either in your PATH, or "cd" into the "tools" directory where your Android SDK files are.

  2. Enter your keystore password when prompted (you didn’t forget that too, did you? Did you?)
  3. See results! You should see something like the picture below if you did everything right. The alias is circled in yellow. If you have multiple aliases in your keystore, they will all be listed, one per line.

Continue reading

Zero to App in Two Weeks with Titanium

Like any web developer who has been sitting on the sidelines watching this mobile explosion happen in front of my eyes, I was eager to find a way to jump in. Up until about a month ago, I was still evaluating various different mobile development platforms – Titanium, PhoneGap, and Rhomobile, trying to decide which one I wanted to use to make my first mobile app. My only selection criteria was that the platform would have to be able to produce both iPhone and Android apps with the same code, because I wanted to be able to develop and release both an Android and iPhone apps without having to learn two completely different programming languages and development environments, and without having to do everything twice.
Continue reading