Your SlideShare is downloading. ×
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Mobile Devices
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mobile Devices

301

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
301
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Running On Mobile How mobile device is different from desktop, and what you can do about it
  • 2. Mobile Device Characteristics • Always around • Always connected • Used for both urgent tasks and fun
  • 3. Users’ Expectations • Battery lasts forever • Apps work smoothly • Seamless app switching
  • 4. Developer’s Perspective • Interruptions will happen all the time • Consider battery in everything you do
  • 5. Some stats onsible for -ser ving resp droid apps ad An atter y drain app related b 75% of
  • 6. Mobile Architecture • Application Sandbox • Getting out: • • • Using OS services Talking to other apps Background Execution
  • 7. Let’s start with a desktop • On a desktop: • File separation is user based • A user can access all her files, everywhere
  • 8. Let’s start with a desktop 1 file = File.open(“/Users/ynonperek/tmp/test.sh") 2 file.each do |line| 3 print line 4 end
  • 9. Mobile Is Different • Basic entity is the App Mobile OS WhatsApp Mail Facebook
  • 10. Mobile Apps Storage: iOS
  • 11. An app storage options • Saving files on the file system • Saving data in preferences (registry) • Hybrid: Leverage browser storage
  • 12. HTML5 Storage Online/Offline functionality Persistant storage
  • 13. Local Data Storage • How do you store data on a client’s machine ?
  • 14. Cookies
  • 15. What’s wrong with cookies? • Before HTML5: cookies were used to store data on the client side • Cookies Disadvantages: • Limited size (4k) • Sent with every request • Complex to use
  • 16. Local Storage • A JavaScript API for storing client side data • Can store up to 5MB (per site) • Simple API • Never run out of space
  • 17. Local Storage API • Store data:
 localStorage.setItem('username', 'bob'); • Read data:
 var stored_username = localStorage.getItem('username'); username = stored_username || 'Anonymous'; • Remove data:
 localStorage.removeItem('username');
  • 18. Q&A
  • 19. Offline Application Cache Dealing with low connectivity (without stealing)
  • 20. Offline Web App • Online-Offline Apps • Sync with the Cloud, but can suffer a downtime (Think Google Gears) • Can run completely offline app as a standalone • Mobile - Save bandwidth
  • 21. Offline Web App GET MANIFEST CACHE MANIFEST index.html style/main.css script/main.js
  • 22. Cache Manifest File • Lists all the files that should be stored for offline access • Enable with:
 <html manifest="example.appcache">
  • 23. Demo • Application with a cache manifest • Modifying manifest and updating
  • 24. Manifest - The Good • Can store any file locally • Provides offline/online app functionality • Transparent to the user
  • 25. Manifest - The Bad • Not suitable for data storage • Complex update logic
  • 26. Sensitive Data Storage • Both iOS and Android support a keychain • Safe storage for sensitive data managed by the OS
  • 27. iOS Keychain Demo Init KeychainItemWrapper *keychainItem = ! [[KeychainItemWrapper alloc] ! initWithIdentifier:@"YourAppLogin" ! accessGroup:nil];! Save username/password [keychainItem setObject:@"password you are saving" forKey:kSecValueData];! [keychainItem setObject:@"username you are saving" forKey:kSecAttrAccount]; Retrieve username/password NSString *password = [keychainItem objectForKey:kSecValueData];! NSString *username = [keychainItem objectForKey:kSecAttrAccount];
  • 28. Pop Quiz • Planning a twitter clone, what data would you store and how?
  • 29. Storage: Keep In Mind • Storage helps you be prepared for interruptions • Store application state whenever it matters • Don’t let a user type twice
  • 30. Q&A
  • 31. Talking to Other Apps
  • 32. The problem… • In a sandbox, we can’t access another app’s data • Desktop “start external process” is also not an option
  • 33. Solution: URL Schemes • Each app can register itself as a valid handler for some link type • Each app can open an external link • OS connects handler with action
  • 34. Solution: URL Schemes Instagram register scheme instag:// iOS
  • 35. Solution: URL Schemes CoolCam open link instag://photo/upload iOS other request data iOS Instagram instag://photo/upload
  • 36. Demo: CoolNotes • Register a scheme handler for: 
 cnotes://! • Add notes to app from another app or web
  • 37. What Next • Both Android and iOS support attaching files to other applications • That requires launching from a native app
  • 38. Online Resources • Registering custom URL scheme on iOS:
 https://github.com/phonegap/phonegap/blob/ master/lib/ios/guides/Cordova%20Custom%20URL %20Scheme%20Handling.md • Registering custom URL scheme on Android:
 http://blog.cttapp.com/p/phonegap-handleopenurlfor-android/
  • 39. Q&A
  • 40. Background execution Abusing a user’s phone when you’re not running
  • 41. iOS vs. Android • iOS is more limited in background execution • Both allow apps to run when not in background
  • 42. Android Services • Non-GUI part of a program • Can run while app is not active • Can be used from other apps
  • 43. iOS Application States • iOS4 Added support for background execution
  • 44. iOS Moving To Background • By default all apps continue some sort of background activity • Acting friendly is your responsibility
  • 45. Background Activity • By default main thread of the application is suspended • Other threads (network) keep working • Demo
  • 46. Background Activity • It’s possible to request main thread to stay active ~10 minutes after suspension • Demo
  • 47. Background Activity • Apps that integrate with OS services can request to handle events • Services include: audio, location, voip, externalaccessory, bluetooth, network fetch, remote notifications
  • 48. Discussion • What are user’s expectations from apps running in the background ?
  • 49. Abusing Mobile Devices • Keep GPS on while app not running • Send small analytics network packets to your servers • Perform CPU intensive tasks while app not running
  • 50. Q&A
  • 51. Thanks For Listening • Ynon Perek • http://ynonperek.com • ynon@ynonperek.com

×