Friday, 23 May 2014

ExactTarget MobilePush setObjectForKey: object cannot be nil (key: app_version)


Recently I've been integrating the ExactTarget MobilePush SDKs into the Android and iOS code running behind my Cordova/Phonegap app. It hasn't been plain sailing due to documentation that isn't too brilliant, slow comms from the SalesForce team, and technical hurdles that are difficult to find answers to.

One problem was a crash when running my iOS app with the newly-integrated ExactTarget MobilePush iOS SDK. I kept getting this error:

Uncaught exception: *** setObjectForKey: object cannot be nil (key: app_version)

At first I thought this may have arisen because my app was yet to be provisioned by ExactTarget, and it was their code causing the error, and perhaps it might fix itself once I had received notification that I had been provisioned. Finally after a couple of days I received this notice, but alas the error persisted.

After more research I discovered that my app didn't have an Info.plist entry for "Bundle versions string, short" (or CFBundleShortVersionString in the source). Once I added this my error disappeared!

Wednesday, 21 May 2014

Retrieve the SHA1 fingerprints of the Android Debug Key

Note to self. How to retrieve the SHA1 fingerprints of the Android Debug Key using a Terminal window:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v

And the output looks like this:


Tuesday, 20 May 2014

Git checkout error: Unable to unlink 'plugins/...'

Had a strange git error today when finishing a GitFlow release on my PhoneGap/Cordova app. It was occurring when it seemingly tried to checkout master, and then would fail, leaving a whole heap of dirty unfinished work in my develop branch.

So I hard-reset the dev branch and attempted to checkout master manually. Same error - 'unable to unlink' and then lots of references to a certain geolocation plugin in the /plugins/ dir. Looking in detail at this directory it was clear that it had different ownership to all the other dirs. Everything else was owend by edpitt, but this was owned by 'root', for some unknown reason. So I ran a 'sudo chown -R edpitt /plugins/org.apache.cordova.geolocation' to turn it back to the correct ownership.

Once this was complete I was able to checkout master with no errors, and so attempting a GitFlow release this time proved successful.

Tuesday, 13 May 2014

Android 4.4.2 tap event registering when unhiding element

This is weird. I have two images of a heart, one grey, one red. I use them to allow a user to 'favourite' an item in a list. When the grey heart is tapped I hide it and show the red heart. When the red heart is tapped I hide it and show the grey heart. Simple huh? You can see them in this pic here:



The code looks something like this:
       
      $( ".greyHeart" ).bind( "tap", function( event ){
                    
              $(this.parentNode).addClass('favourited');
              $(this.parentNode).removeClass('notFavourited');
                    
               //store data in array in local storage
           
        });

       $( ".redHeart" ).bind( "tap", function( event ){

              $(this.parentNode).addClass('notFavourited');
              $(this.parentNode).removeClass('favourited');
          
             //remove data from array in local storage

        });

This all works brilliantly across my desktop browsers, iOS and most Androids. Except 4.4.2.

In 4.4.2 it seems that the tap event is detected on the grey heart and then again the tap event is detected on the red heart too when it appears under the user's finger. The user sees the heart turn red then immediately grey again.

To get around this odd behaviour I had to change my code to immediately unbind tap events on detecting a tap, and then rebind them after a small delay.