Author Archives | Roger

Successful iOS Background Location reporting

We’re working on a location product right now and one of the little challenges along the way has been how to report background location updates back to our servers.

First, some basics.

We’re going to be using the Significant Location Changes feature introduced with iOS 4 as this is the recommended way of tracking the approximate device location in a low power way. As always, the Apple documentation is excellent and is worth reading so you are aware of the detail.

Note the really key features here;

a) If the application is suspended when an update occurs, the system wakes it up in the background to handle the update.

b) If the application starts this service and is then terminated, the system relaunches the application automatically when a new location becomes available.

That’s just perfect, so what we can now do is turn on significant location updates when the user hits the home key and we can let the system wake us up when needed.

-(void) applicationDidEnterBackground:(UIApplication *) application
{
    // You will also want to check if the user would like background location
    // tracking and check that you are on a device that supports this feature.
    // Also you will want to see if location services are enabled at all.
    // All this code is stripped back to the bare bones to show the structure
    // of what is needed.
 
       [locationManager startMonitoringSignificantLocationChanges];
}

Then to perhaps switch to higher accuracy when the application is started up, use;

-(void) applicationDidBecomeActive:(UIApplication *) application
{
       [locationManager stopMonitoringSignificantLocationChanges];
       [locationManager startUpdatingLocation];
}

Next you’ll likely want to change your location manager delegate to handle background location updates.

-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    BOOL isInBackground = NO;
    if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)
    {
        isInBackground = YES;
    }
 
    // Handle location updates as normal, code omitted for brevity.
    // The omitted code should determine whether to reject the location update for being too
    // old, too close to the previous one, too inaccurate and so forth according to your own
    // application design.
 
    if (isInBackground)
    {
        [self sendBackgroundLocationToServer:newLocation];
    }
    else
    {
        // ...
    }
}

OK, so now to the crux of it all. If we are running in the background, we can’t just use the network as we would normally. In background mode the iOS controls very strictly what is allowed, and for how long it is allowed, so if we were just to send the location to our server as normal, we will find this will be highly unreliable. It may work sometimes, it may not, and you will have no control over what is going on.

We can however TELL the operating system in advance that we are doing a background task that should be allowed to run to completion. By doing this, we can ensure that our network activity is given enough time to complete and so the remote server will get the location updates OK.

-(void) sendBackgroundLocationToServer:(CLLocation *)location
{
    // REMEMBER. We are running in the background if this is being executed.
    // We can't assume normal network access.
    // bgTask is defined as an instance variable of type UIBackgroundTaskIdentifier
 
    // Note that the expiration handler block simply ends the task. It is important that we always
    // end tasks that we have started.
 
    bgTask = [[UIApplication sharedApplication]
               beginBackgroundTaskWithExpirationHandler:
               ^{
                   [[UIApplication sharedApplication} endBackgroundTask:bgTask];
                }];
 
    // ANY CODE WE PUT HERE IS OUR BACKGROUND TASK
 
    // For example, I can do a series of SYNCHRONOUS network methods (we're in the background, there is
    // no UI to block so synchronous is the correct approach here).
 
    // ...
 
    // AFTER ALL THE UPDATES, close the task
 
    if (bgTask != UIBackgroundTaskInvalid)
    {
        [[UIApplication sharedApplication} endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }
}

The key to this whole process is the use of background tasks to ensure that our synchronous network activity is given enough time to complete. This lets us update a couch database for example where we might need to make 1 network call to get the current document revision and then a second network call to actually PUT the new data.

Posted in iPhone Development4 Comments

Viewing iFolder’s FLAIM store with StoreBrowser

In the midst of debugging login issues with Novell’s iFolder, I stumbled over this post about a tool for accessing the FLAIM database that underpins the whole system.

One of the problems is that the tool itself seems to have vanished from the trunk repository and so its existence was not at all obvious. There seem to be a few people having problems finding it and so I thought it worthwhile including the storebrowser files here so that you can get up and running more easily.

I’m going to document running StoreBrowser on your SERVER first. I’m assuming that you have a standard installation running on OpenSUSE 11.3 as that seems the best open source option at the current time (April 2011).

1) Download the zip package and unzip to a suitable location on your system.

2) Open a terminal window and navigate to the folder containing the StoreBrowser.exe file. It is important that you cd to this location as otherwise you will not be able to run it correctly.

3) Copy the asmx file to the appropriate place. This is OS specific and this guide is for OpenSUSE 11.3

cp SimiasBrowser.asmx /usr/lib/simias/web/

4) Ensure you have the directory ~/.local/share/ you may well need to mkdir ~/.local and then mkdir ~/.local/share .This location is used by the application to store its config data and it won’t auto create it, it will just complain.

5) if  echo $DISPLAY shows nothing in your terminal, enter the following command

export DISPLAY=:0.0

It is important to set the display otherwise mono will abort with an error like this;

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI —> System.ArgumentNullException: Could not open display (X-Server required. Check you DISPLAY environment variable)

6) mono StoreBrowser.exe

If all is well, the application should launch with an empty window. First click on file and select Open Store as shown below;

After selecting Open Store, you will need to enter the url for the local simias store. For example this will typically be http://localhost/simias10

Click on OK and assuming all is well, you will be prompted to login. You need to enter your ADMIN username and password in order to access the store, normal user accounts won’t do.

Once logged in, you will see the store tree to the left, however there is actually more to see but it’s hidden to the right of the window. To make it visible, drag the bottom right corner of the application window to enlarge it, and then drag to the left the dividing line that you will be able to see when you enlarge the frame.

You should end up with something that looks like this;

If you expand the Store and select an entry, you will get screens like this;

You can edit items by double clicking them. BUT FIRST A WARNING. MAKING ANY CHANGES TO A LIVE SYSTEM COULD RESULT IN THE LOSS OF YOUR DATA. This is a low level debugging tool that should be wielded by experts (feel free to get in touch if you know any!) and making changes could leave your system in an unstable state. Don’t go editing and deleting things and then complain to me afterwards that all your users have lost their data … it will be your fault not mine.

Don’t say I didn’t warn you …

 

 

Posted in iFolder, iPhone Development0 Comments

iFolder on VirtualBox (part one)

Today I’m going to put together a complete walk through for getting your very own iFolder server up and running on a virtual host on your Apple Mac.  iFolder is notoriously difficult to install but thanks to Daniel Lench, there is now an excellent tutorial over on his blog.

I’m taking it a tiny step further by documenting the process with screengrabs and showing how you can do this with Oracle’s VirtualBox.  We chose Virtualbox over VMWare because on the Apple Mac, VMWare Fusion is not free whereas Virtualbox is. The instructions for VMWare would be different, but the intent would be the same.

 

Click on New to create a new virtual system

 

Fire up virtualbox and click on the blue NEW icon to start the process of creating a new virtual system.

 

 

Click Continue

 

Give it a name and ensure you choose Linux / OpenSuse

 

The default RAM is tight, but OK for this demo. Increase it on a real deployment.

 

Click Continue

 

Now we will be asked about the virtual hard drive we will need.

 

Continue

 

Continue

 

Continue

 

Done

 

Now we are asked to confirm the virtual machine we are going to create.

 

Done

 

And we’re done … or rather we now have an empty virtual machine that we can install the base operating system onto and then begin setting up for iFolder.

 

And there it is ...

 

It’s important to note at this stage that we are yet to put an operating system onto our virtual machine, and before we do that, we need to have some installation disks available.

iFolder is currently not qualified for OpenSUSE 11.4, so we need to download an installer for OpenSUSE 11.3 which we can grab from software.opensuse.org/113/en it is a big download, so kick it off and make yourself a nice cup of tea!

Download the DVD and make some tea!

 

Once you have the ISO on your computer, we can fire up the virtual machine and install OpenSUSE onto it.  So first of all START the virtual machine we have just built and we’ll get the first run wizard.

 

Continue

 

Click the folder icon so we can browse to our ISO

 

Navigate to where our newly downloaded ISO file is.

 

Navigate then click Open

 

 

Continue

 

Done

 

Our virtual machine will now launch, boot from the virtual install DVD and we can begin the installation proper.

 

Select Installation and off we go ...

Rather than duplicate the official guide on how to proceed from here, I’m going to hand you over to the experts at Novell who have already prepared a full walk through on the simple installation procedure.  The complete OpenSUSE installation guide for 11.3 can be found here.

In the next part, I’ll show you how to install the pre-requisites that you are going to need in order to install iFolder.

 

 

 

Posted in iFolder0 Comments

iFolder for iPhone now available!

UPDATE: The first release is now available in the app store. At the moment it’s US only but we expect to do a global release by the end of February 2011.

Available in the US App Store

We’ve just put the finishing touches to our iFolder for iPhone app and are recruiting enterprise beta testers who have their own iFolder installation. The easiest way of describing iFolder is probably to say that it’s dropbox for the enterprise – it’s a cross-platform secure file sharing system originally developed by Novell and now open sourced. There are existing open source clients for Windows, Apple Mac and Linux, but mobile support is currently limited (well, non-existent).

You can check out the app and apply for the beta programme over at ifolder.mindsizzlers.com

Posted in Development, Featured, iPhone, iPhone Development, News0 Comments

MP Finder iPhone app released

MP Finder iPhone app released

Our latest iPhone application is a small demonstration of what can be achieved using the newly released data from The Ordnance Survey under the Open Data initiative combined with public domain data on Members of Parliament and Constituencies.

MP Finder locates where you are and then drops a pin on the map identifying your constituency and MP. No entering postcodes, searching for addresses, simply turn on and find your MP!

Visit the app store

Posted in Featured, iPhone, iPhone Development, News, Products0 Comments

OS Open Data Shapefile to KML

In early April the Ordnance Survey released a whole set of previously expensive geographic data into the Open Data initiative. The data is often in ESRI shapefile format as that is pretty much the norm for GIS software. That’s great if you are taking the data into a GIS workstation, but what if you want to turn the data into XML or JSON for use in a web service for example?

That was the problem I faced last week when working on the MP Finder application that should soon hit the Apple app store.

My specific goal was to turn the shapefile data into KML as an intermediate format which I could then write a perl parser for. KML is great as an intermediate format because I can visualise it in Google Earth to check that the export has gone OK and of course it is a structured document expressed in XML – so it’s perfect for machine parsing.

It turned out to be not quite as easy as I first thought.

The issue was the sheer length of some of the polygons in the shapefile, and more specifically northern Scotland which has a crinkly coastline to rival that of Norway. This was causing a lot of software to either crash, or silently dump the datapoints over a certain threshold. Not good.

The solution was to use the snappily named “ogr2ogr” tool which forms part of the toolset compiled by Frank Warmerdam and released as FWtools.

My first attempt was to use the simple command;

ogr2ogr -f KML output.kml input.shp

And whilst at first glance this seemed to have worked, the data points in the polygons were certainly not latitude and longitude. The problem was the map projections were not matching and after a bit of research and a big clue from stack overflow, I corrected the projection using the new command;

ogr2ogr -t_srs EPSG:4326 -f KML output.kml input.shp

Now we have a correctly projected KML file of the original shapefile data. You can test it by viewing it in Google Earth and more importantly, now that it is in KML it becomes trivial to write a parser to extract the data you might require … but that will be the subject of another post altogether.

Posted in Development, iPhone, iPhone Development0 Comments

iAd – mobile advertising for iPhone

The announcement from Apple today about the new OS 4 for iPhone was pretty much as expected with the main developer interest being multi-tasking (only on 3GS and newer devices). More interesting was the announcement about iAd, Apple’s new mobile advertising platform that aims to integrate advertising more tightly with the whole iPhone experience.

This is potentially great news for developers. Up to now we’ve been largely limited to advert banners that cause our applications to quit and whizz off to a mobile web page. Since many users are probably clicking the adverts by mistake, as they are often close to a tab or navigation bar, this is really annoying for them since the application has now quit to launch the web browser. This means many developers are reluctant to put advertising on their applications, the users don’t like the experience, and all in all it’s not a recipe made in heaven.

iAd aims to change that by keeping the adverts within the application experience. This is potentially great news. Users won’t be so annoyed because they will now have an easy way to simply click back to where they were in the application. This in turn means developers are more likely to be able to earn a small crust from their free apps (Apple are taking 40% of the advertising revenue and giving you the other 60%). The likelyhood is that the quality of the adverts may also improve to become more engaging and this could lead to a win win situation all round.

What we would not like to see would be ads in PAID apps, that is likely to really alienate users, but I’d be willing to bet that the better the advert experience is for the user, the more we will see careful deployment of advertising in these as well.

It should be an interesting summer …

Posted in iPhone, News0 Comments

iPhone Training Courses

Mindsizzlers are now running London based training courses on iPhone and iPad development for both programmers and business leaders.

Developed over the course of the last few months, courses can be delivered either at The Bridge in East London, or on-site for your own company. Courses can be scheduled in different ways to suit the participants so please do get in touch if this is something you think we can help you with.

Please get in touch for more information.

Your Name (required)

Your Email (required)

Your Message

1+1=? 

iPhone for Business Leaders

Many companies are looking at the iPhone and other mobile platforms as a business tool, either with staff able to access IT infrastructure, or to develop apps to compliment, extend or advertise existing services. This one day course looks at the practicalities of iPhone as a platform, introduces the application lifecycle and gives participants an insight into how to manage an iPhone project.

More Details

iPhone Programming

This three day course is intended for programmers wishing to learn how to write iPhone applications. Participants should have some programming experience, object oriented programming experience is not a prerequisite. Participants will learn about the iPhone platform, its native programming language, Objective-C, and be introduced to the business processes behind creating and publishing apps in Apple’s app store. By the end of the course, participants should have enough understanding to create and build their own applications, be familiar with the development environment and iPhone API’s, and have an understanding of a broad range of the technologies and concepts underlying iPhone
programming.

Courses are run in association with our friends at The Bridge

Posted in iPhone, News0 Comments

Golden Hour comes to iPhone

Golden Hour comes to iPhone

Mindsizzlers have released their latest iPhone application. The Golden Hour app’ puts a sun clock in your pocket and allows you to plot the position of the sun for any location on earth and time of year. Of particular interest to photographers, the application highlights the so-called “Golden Hour” much appreciated by cinematographers and photographers alike.

Featuring a comprehensive database of over 45,000 locations around the world, accurate astronomical calculations and different views of the data, both graphical and numeric, the application is designed to accompany and augment the existing website at www.golden-hour.com.

Full Features;

Next event alert for the current location.

Sun clock display showing not simply the day-night terminator, but a coloured shadow highlighting the areas of the planet currently in golden hour, civil twilight, nautical twilight etc. Click on the map to instantly change locations.

Sun Angle display showing the Azimuth and Elevation for any time on the current day.

Golden Hour display, familiar to website users this is the core display of the solar altitude during the day. Users can scroll through the year or nudge the current date up/down with a tap. From this screen users can also access a comprehensive numeric data view showing the full range of astronomical,nautical and civil twilight times.

Huge drill down location database complete with full colour flags of the world for each country and population data for each city, town or village.

Particularly noteworthy is that the application does not require any network access and is therefore perfect for iPod touch users.

Posted in Featured, iPhone Development, News, Products0 Comments

How does a large plastic map win a UK innovation award?

Today I was a delegate at the Geovation 2010 awards in London.  According to their own website, “Geovation is a place where innovative thinkers and geographic data can get together for the benefit of developers, entrepreneurs, website owners, end users and the wider community.”

The stress is mine, but you would kind of imagine that the very name “Geovation” would suggest innovative use of Geography … well that’s certainly what I was expecting.

The plan for the day was to listen to some pitches, vote on the candidates and then see who the esteemed judges had chosen to win a share of the prize fund.

So … with much anticipation I turned up to see the presentations about Innovative uses of Geography.  I have to admit to being a little disappointed.  There were some good ideas, and for me, one stood out head and shoulders above the rest … but I am struggling to work out how 2 (yes, TWO)  rather similar large plastic maps made it into the final. Even the Q&A session after the second presentation was asking what the difference was to the other entry (albeit couched in diplomatic language).

So to be clear. The FINAL of a UK Government sponsored (ultimately, since it was funded by the Ordnance Survey) initiative concerning INNOVATION in geography yielded 2, er, large plastic maps. Even better, they were both aimed at use in schools! Nothing wrong with that per se … but basically both “innovations” were conceptually identical and targeting the same group.

OK I thought, it’s a shame we have 2 plastic maps in the final, but the other 7 finalists will surely bring something interesting to the table. Well … yes and no.  There were other ideas, a few of which definitely had some merit, and whilst I quite agree that simply sticking something on the iPhone doesn’t render it innovative, there were some genuinely good ideas about the use of geography and technology that would have filled the brief by being called “innovative”. One of the ideas was exceptional, so much so that on my voting form I only ticked one box (rather than the two I was being asked for) and wrote in the margin, “give all the money to these guys as it was by far the best idea”

But back to the maps.

The first shocker was that the “community award” – ie the one voted for by people in the audience, overwhelmingly went to one of the large plastic maps. I found that hard to believe, and was wondering how many innovators there were in the audience … and then, to my absolute amazement, the judges awarded first place to, wait for it … the very same large plastic map!

Now don’t get me wrong, the people involved were clearly dedicated, passionate, well connected and motivated … but come on guys, we are talking about an INNOVATION award here. Large plastic maps were innovative round about the time we invented PVC in 1872 – although to be fair no practical use for PVC came about until the late 1920′s. But hey, that’s not quite 100 years ago yet so there is still plenty of room for innovation eh ;-)

So I came away not knowing quite what to think. I did have some interesting chats in the pub afterwards (and thank’s for the beer guys) and many of the entrants were both innovative, practical and interesting … but come on Geovation … to award the top prize for geographical innovation in the UK to a LARGE PLASTIC MAP does none of us any favours in UK PLC.

Posted in News, Personal3 Comments

Advert

For more information about our services…

Contact Us

Wordle of the Day

Image from software at http://wordle.net
Data by Web Trends Now

Categories