Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Friday, 9 September 2011

iOSDev UK: Design Considerations for Educational Apps

Fraser Speirs, Head of Computing & IT, Cedars School of Excellence, @fraserspeirs

http://speirs.org

  • last year gave every child an iPad
    • only 100 pupils
    • had 220 people come to visit the school…
  • when you give people the internet the whole time, you sometimes get unexpected results
    • Fraser showed a slide of coursework on cell nuclei, decorated with a background showing the Statue of Darth Liberty
  • sitting around iPads — everybody faces each other rather than all facing the screen at the front
  • avoiding the ceremonial computer lab — moving to casual computing
  • beautiful artwork created by kids on iPads, within a month of receiving them
  • it’s not just the iPads, it’s the 1:1 — the 1:1 is more important
  • Fraser’s daughter is 4.5 — just started school
    • will graduate from university in Summer 2029
    • “we are already teaching the citizens of the 22nd century”
  • looking at investment as kids’ chairs & tables
    • not as a guarantee that scores will go up

Do’s and Don’ts for apps in schools

  • don’t assume the internet works correctly
    • schools change what internet is available through frequent policy changes
    • youtube is often turned off
  • teaching fashions come and go regularly
  • in-app purchase doesn’t work in schools
    • central purchasing or gifting
    • e.g. PCalc has a full version that can be purchased at once
  • don’t assume your users can (will) read
    • use conventions wisely (keep the back button in top left corner)
  • use push notifications sparingly
    • no good advertising to kids in school — they don’t have the app store password anyway
  • watch out for number of devices nearby
    • could be 20-30 devices around
    • infrastructure may cope, but leave room in your UI
  • limit or prevent app store interactions
    • no good in schools
    • confuses kids; annoying for teachers
    • that goes for “review me now” too
  • teachers need access to content
    • support the photos app
  • don’t promote facebook
    • facebook can be a major source of anxiety for many children
  • watch out for shaking gestures — not good for
  • don’t use bad language (and try to avoid double-entendres and local slang too). Some examples:
  • be very careful with user data — especially with location
  • talk to teachers and test with actual children
    • Fraser’s school does not have the scale to be a beta tester…
  • watch out for different curricula in different countries
  • walk through guide in the app
  • kids can use loads of apps to edit graphics, passing the image through the photos app
  • use sharing effectively
    • use “Open In…”
    • avoid huge sharing option lists
  • show proof of completion
  • avoid (penalise) random hits
  • structure + headroom = creativity
    • app idea: make toontastic for creative writing
  • show user activity
    • e.g. Brushes lets you record all your strokes and play them back as a quicktime video
  • localisation is useful even if your app is UK-specific
    • e.g. Iraqi boy with a 1:1 iPod touch switched it to Farsi and used Google Image Search to show pictures of what he wanted to the teacher
  • support projectors & AirPlay
    • don’t offer resolutions for external display — just pick one and do it well
  • there is a control to turn off Game Center at a policy level
    • so go ahead and put it in the app but make the rest of the app work without it
  • gap in the middle for 7-10 year olds
    • need more apps like toontastic — structure provided, but space for creation
    • older kids can use general content apps
    • younger kids don’t need so much freedom
    • using iThoughts HD for mindmap, then writing in Pages

example apps

Q&A

  • research?
    • study with university of western scotland
    • two lessons back to back: one with iPad, one with paper & pencil
    • same teacher, same children
    • with paper & pencil, boys and some girls had less emotional engagement
    • with iPad emotional engagement of all pupils was brought up to same level as best kids
    • being submitted to BJET, but may not be published yet
  • separate educational version of an app?
    • kids want the real thing
    • universal design is best
    • Fraser tries to buy things off the shelf rather than waiting for educational specific versions
  • damages?
    • only had one — parent ran it over with Land Cruiser!
    • kids are careful — the iPad has their name on it
  • teachers adapting to technology?
    • about half of the teachers had iPhones/iPod Touches before the programme started
    • the iPad is significantly more approachable than other computers
  • how do you find apps?
    • school subscribes to Tap! magazine…
    • more popular than the TES :-)

Thursday, 8 September 2011

iOSDev UK: Adapting Content for Apps

Dave Addey & Alyson Fielding, Agant Ltd, @daveaddey & @alysonf

  • Why an app?
    • Can you do something with it in dead time?
    • It’s always there when you need it
    • Would you use it yourself?
  • Preparing content
    • content definition lets you split up content into small pieces
  • iPhone vs iPad
    • use cases are different
    • e.g. full page illustrations just don’t work on an iPhone — universal app just doesn’t show them
  • network content:
    • assume no network and make as many things possible as you can
    • then download & cache what you need when network becomes available
    • same goes for submitting stuff — add it to a queue and submit it when a network becomes available
    • e.g. QI app submit a fact
    • provide the app bundle with some initial content to get started
    • if you have information always show it — but show how old it is

content formats

  • HTML
  • Property list
  • Custom XML
  • NSAttributedString
  • Core Data store
  • SQLite database
  • bundled media files
  • text files — e.g. QI facts to rate
  • PDF
  • e.g. QI app
    • books came as ePub (HTML)
    • needed tidying, but was very useful
    • errors could be spotted & fixed directly
    • however, not the right format to put in the app
    • used script to transfer into NSAttributedString
    • better presentation
    • better layout for images & text
    • better pagination
    • content definition really helped
  • e.g. Malcolm Tucker
    • email views driven from plist
    • Aly edited directly in XCode and rebuild to check
    • email content in HTML
    • attachments in PDF
  • e.g. Arsenal app
    • already had a CMS for the website
    • beginning of project — defined an API
    • tweaked the API throughout development, but had something to work from right at the beginning

Helping content experts

  • work hand in hand with them from the beginning
  • make sure they have a real device that they’re using every day
  • try to let the content expert able to make their own build of the app as they change the content
    • anyone working on the content has XCode installed and knows how to build it
    • they also have access to check stuff back in
  • let them play with your toys — it’s fun!
  • put the content in with the development

stats

  • 2.7 million stations are picked from UK Trains picker every month (~88k per day)

Q&A

  • testing
    • looking to do more
    • UI testing is a bit of a faff, but is possible

iOSDev UK: Real-World Data (or There and Back Again)

Hamish Allan, Olive Toast

The story of writing Files Pro — an app to take files with you on an iOS device.

  • Used Deusty’s CocoaHTTPServer
  • Dropbox has a nice API
    • operations are aynchronous
  • Gamekit makes device to device connection over bluetooth easy
  • Could use HTML5 to make a PC-based interface to an iOS app
    • Visit a web page served from the device from your PC and see a flexible app within your browser
  • iCloud
    • NSFilePresenter tells you when a file transfer has completed
    • iCloud syncs the meta-data about files first, using NSMetadataQuery
  • “Your market is not power users”
  • Apple is moving towards a flat list of files with search, rather than a hierarchical system

Q&A

  • No hooks in iOS for AirDrop (yet?)
  • Nor any GameKit APIs which talk to desktop

Thursday, 12 November 2009

Apple iPhone Tech Talk London 2009: Networking: From Sockets to GameKit

Paul Danbold danbold@apple.com — Evangelist

This was another really fast presentation with loads of detail. I look forward to grabbing the presentation from the iPhone dev site.

  • don’t want to use CFSocket or BSD Socket
    • don’t let you bring up wireless, or involve security
  • service discovery:
    • NSNetServices, CFNetServices, dns-sd, BSD Sockets
    • dns-sd is Bonjour or Zeroconf

URL Loading system

  • NSURLRequest, NSURLConnection & about 10 other classes (also mutable ones)
  • there’s sample code for validating URLs
  • recommend to use asynchronous API style:
    • use delegate mechanism — calls connection:didReceiveResponse:
  • also connection:didReceiveAuthenticationChallenge:
  • finally connectionDidFinishLoading:
  • default behaviours should work fine

Local area networking — service discovery

  • kick off NSNetServiceBrowser in asynchronous mode, w/delegation
  • browser searchForServicesOfType:inDomain:
    • e.g. type _http._tcp in domain local. — don’t go beyond any routers
    • can look for your own types too such as _foo._tcp
  • then get myServiceBrowser:didFindService:moreComing:
  • call NSNetworkService getInputStream:outputStream to resolve
    • this takes time (many seconds)
    • wait for the user to choose before resolving
    • and let the user decide when to cancel
    • resolveWithTimeout:0.0
  • must release input & output stream objects returned by NSNetService
    • bug in Apple’s code — doesn’t obey normal Cocoa behaviour

OutputStream & InputStream

  • NSStreamEventHasSpaceAvailable is probably the interesting one
  • though you want to handle the errors too…

advertising & publishing

  • advertise service with NSNetService initWithDomain:type:name:port
    • domain can be empty — means local
    • name can be blank too — will use device’s iTunes name
  • then call publish on service

stop when you’re done

  • browsing is fairly lightweight on the network, but you should stop anyway
  • the same goes for publishing, when you’ve got all your connected clients

register types & ports

game kit — peer to peer

  • 3.1 adds WiFi support as well as Bluetooth
  • GKSession initWithSessionID:displayName:sessionMode
    • session ID is your Bonjour service type — how you advertise yourself
    • again, can leave displayName as nil for iTunes name
    • sessionMode can be peer to peer (1 to 1) or client/server (multiple clients)
  • can’t physically go over 10-20 clients with Bluetooth
    • 3.1 and later is a lot better, but still no more than 3-4 clients
    • Bluetooth also has low bandwidth
  • set up delegate and set available to YES
  • check other peers with peersWithConnectionState:
    • can be available, already connected, in the process of getting connected
  • connectToPeer:withTimeout:
    • generally set timeout to zero to let user cancel if they want
  • actual connection made with session:didReceiveConnectionRequestFromPeer: and acceptConnectionFromPeer:error:
  • must monitor the network using session:peer:didChangeState:
    • other players can drop out, so you’d have to tear down your session
  • send data with sendDataToAllPeers:withDataMode:error: and sendDataToPeers:...
    • can choose unreliable (UDP) or reliable (TCP) data modes
    • as always TCP imposes a performance cost so use sparingly
  • receive data with setDataReceiveHandler:withContext: and receiveData:fromPeer:inSession:context:
  • always check for errors — buffers fill up on low bandwidth networks
    • check it by using a slow network
  • when you’re finished, tear down with disconnectFromAllPeers:
  • there’s a GKPeerPickerController for setting up Bluetooth peers
    • doesn’t work for client/server or WiFi
  • the only way to find out if Bluetooth is turned on is to use the GKPeerPickerController (it uses private APIs…)
  • all data sent & received is NSData-wrapped — design your packaging for network efficiency first and coding efficiency second

Voice chat

  • GKVoiceChatClient and ~Service
  • sets up socket interface
  • handles microphone, echo suppression, etc

network challenges

scoped routing and reachability

  • iphone 3.0 and later provides scoped routing
    • keeps both cellular and wifi up at the same time — so cellular connections keep going when you enter a wifi hotspot
    • but this puts a toll on the battery, so you should behave and check for networking changes
  • use SystemConfiguration APIs to monitor network state
    • Am I on the network and what kind of network is it?
    • cannot tell you that packets will arrive…
    • if network changes, finish what you’re doing, close connection and start a new one
  • use SCNetworkReachabilityRef and check for flags
    • but again use callback APIs since the calls take about 30 seconds
  • no point using this to pre-flight as things may change
    • just use to monitor
  • can set UIRequiresPersistentWiFi key
    • keeps WiFi live while your app is live
    • shows up UI elements automatically (like offering to turn off Airplane mode)
    • but if the device sleeps, you still lose your WiFi connection

battery use

  • listening is cheap, transmitting is expensive
  • 3GS sending leaves the antenna in high powered state for 5 seconds
    • so don’t send every 5 seconds — it will leave it in high power continuously
  • compress data, send large chunks
  • tear down connections when reachability changes

other tips

  • try to use the cache as much as possible
  • try to resume downloads rather than restart
  • use pipelining if poss.
    • ask for lots of things at once and be careful about return order
    • some web proxies and apache configs just break pipelining
  • also use multiple connections
  • but different network conditions and different servers require different tuning
  • test in areas where you know the network is flaky!
  • use a packet analyzer — see QA1176
  • try to isolate the user from network problems
    • often there’s a transient glitch — try again before alerting the user
  • see also Technote TN2152
  • look for developer forum postings by eskimo1 :-)

there’s some new sample code available:

  • SimpleNetworkStreams
  • SimpleURLConnection
  • SimpleFTPSample
  • Reachability — there’s a new version! The old version had bad code :-)
  • BonjourWeb
  • WiTap — peer to peer, but doesn’t use GameKit
  • GKTank
  • GKRocket — work in progress, with voice chat too