Apple:s lösning av multitasking med ett antal API:er som löser de flesta problemet är förstås bra för batteritiden och för vissa typer av appar. Men det är tyvärr helt värdelöst för andra. Appen Instapaper exempelvis borde kunna få då och då hämta hem data i bakgrunden för att kunna vara uppdaterad när användaren öppnar det. Som det är nu iOS 4 så måste appen startas och användaren får vänta på att appen hämtad hem ny data från servern innan appen kan användas för att läsa det senast tillagda materialet.

Marco Arment som är skapare av Instapaper har dock en lösning som han vill att Apple implementerar och som skulle lösa problemet för inte bara hans app utan för exempelvis RSS-läsare och Twitter-klienter med mera.


    Proposed solution: A new multitasking type
    The addition of one more multitasking service would solve this issue for a lot of application types: a periodic network request. Here’s how I would do it:

    • The application gives the system an NSURLRequest and an ideal refresh interval, such as every 30 minutes, every few hours, or every day.
    • iOS executes that request, whenever it deems that it should, and saves the response to a local file.
    • Next time the application launches, iOS hands it an NSData of the most recent response.

    Executing the request “whenever it deems that it should” is important. iOS can decide, for instance:

    • Not to update when the battery is low, connectivity is poor, other requests are running, free memory is low, CPU usage is high, or the user is predicted to exceed their monthly data limit.
    • Not to update as frequently as the app requests, or to increase the interval over time, or to dynamically adjust the interval based on how often it receives a 304 (Not Modified) response.
    • Not to update at all if the requesting app has not been launched in a long time.

    This would allow Instapaper to download updates in the background, and would also greatly benefit RSS readers, Twitter clients, chat programs, weather and news widgets, and a huge number of other applications that currently can’t get much benefit from iOS’ multitasking.

Läs mer på marco.org.


 

Kommentera


© 2010 Teknikveckan