際際滷

際際滷Share a Scribd company logo
WatchKit Pitfalls
Developing iOS App for Dribbble
Zgonik Vova
Register your application
 Website URL
 Callback URL
 Client ID
 Client Secret
 Client Access Token
https://dribbble.com/account/applications/new
OAuth2 solutions
NXOauth2Client GTMOAuth2
 Detailed error handling
 Block callbacks
 No response body on auth error
 NSNotificationCenter
Dribbble API understanding of HTTP response codes
422
Unprocessable Entity
400
Bad request
500
Internal server error
403
Operation is forbidden
 upload shot or attachment without
mimeType
 follow more than 1800 followers
 follow own userId
 incorrect parameter name
 upload limit:
- 48 shots per month
- 5 shots per day
 access denied (canUplodShot = NO)
429
Too many requests
304
Content not modified
404
Not found
204
No content
API restrictions:
 60 requests per minute
 10000 requests per day
 no like shot, like comment
transaction entry found
 no following transaction entry 束A
follows B損 found
 presence of transaction entry for
user 束A follows user B損
 response on delete request for:
like comment, like shot
 if the resource has not changed in
conditional request with parameter
If-Modified-Since
 POST incorrect JSON
Watch kit pitfalls. developing iOS app for Dribbble.
Requests Rate Limiting
low-priority
 check if like shot
 check if follow user
 60 per minute
 10000 per day
high-priority
 account request
 switch & load category of shots
 like shot
 follow user
Apple Watch
watchOS App
WatchKit App
WatchKit app Target
Storyboard
Resources
WatchKit Extension
WatchKit extension target
WatchKit code
and Resources
WatchKit App
IOS App
iOS app target
iOS Code
WatchKit
Extension
WatchKit app stores on
watch device and consist
of storyboard and static
resources (images, fonts)
WatchKit Extension stores
on iPhone and consist of
source and resources
all source executes on
iPhone, without iPhone
Watch app wont launch
NOT SURE OF WHAT IS GOING ON HERE
iPhone
Extension Communication
Glance
Notification
WKInterfaceController
Apple Watch
WatchKit App
Storyboard
Resources
WatchKit
Extension
Code
Resources
WatchKitWatchKit
WatchKit Launch Flow
Launch WatchKit
APP
Load initial
interface controller
Initialize
UI
Display
UI
Storyboard
Interface controller
init willActivate
 user launches app on watch
 watchKit finds initial controller in storyboard and notifies iPhone
 watchKit Extension should be launched and specified class of controller is instantinated
WatchKit
Extension
Watch kit pitfalls. developing iOS app for Dribbble.
Glance
 no interactive items: buttons, switches
 no vertical scrolling
 San Francisco system font only
 Apple doesnt recommend use maps and tables
Notification short look
 no interactive items: buttons, switches, sliders
 allow different typefaces of system font
 allow change tint color with app Name
Notification long look
system stuff
application
content
action defined
in watch app
two types activation mode:
background & foreground
 openParentApplication:reply:
 App Groups
 Darwin-notification
 Handoff
WatchKit Extension and App Communication
Communication
 model classes, web services, credentials
 restricted API:
! any API marked with
NS_EXTENSION_UNAVAILABLE
! calls to UIApplication +sharedApplication
! access the camera or microphone on an
iOS device
! receive data using AirDrop
Sharing code
openParentApplication
API on watch App [WKInterfaceController openParentApplication:reply:]
API on main application: implement (:handleWatchKitExtensionRequest:reply:)
 main app launches in background
 error handling available
- slower than other methods + API calls time increases
- objects should conform <NSCoding>
App Groups
 com.apple.security.application-groups entitlement
 initWithSuiteName: (NSUserDefaults)
 containerURLForSecurityApplicationGroupIdentifier: (NSFileManager)
- main app cant notify watch about new data
Darwin-notifications
Exchange messages between processes in iOS by means of Darwin-notifications
pod MMWormHole
Sending process
Notification
notifyd
routines allow processes
to exchange stateless
notification events
process 1
process 2
process 3
Client processesnotification is just a signal
it can't transport any data apart from
the notification identifier
Handoff
 NSUserActivity in main apps Info.plist
 perform updateUserActivity:userInfo:webpageURL: in WKInterfaceController
 handle activity event in AppDelegate:
- application:willContinueUserActivity
- application:continueUserActivity:restorationHandler
Shot Bucket App
ApiClient
AppDelegate
ShotsViewController
WKInterfaceControllerWatch App
Main App
Core structure
ShotsController
Data source
Networking
ShotBucketCore
Framework
App Models
Oauth2Clients
Api Clients
ActionManager
Gallery on WatchKit
. . . . . . . . .
Gallery on WatchKit
reloadRootControllersWithNames:
contexts:
swipe
Initial
Interface
Controller
swipe
12:0012-0012-00
12-00
Load more
Modal
controller
12-00Close
ContentContent
More pictures?
Page-based Controller Life Cycle Changes
Watch kit pitfalls. developing iOS app for Dribbble.
Smart personalized notifications without backend
Background fetch
Conditional request
Last-Modified: Sat, 22 Feb 2014 17:10:33 GMT
HTTP/1.1 304 Not ModifiedHTTP/1.1 200 OK
Local notification No action
BG Fetch issues
- [UIApplication performFetchWithCompletionHandler:]
UIBackgroundFetchResult
 UIBackgroundFetchResultNewData
 UIBackgroundFetchResultNoData
 UIBackgroundFetchResultFailed
Watch kit pitfalls. developing iOS app for Dribbble.
https://github.com/agilie/dribbble-ios-sdk

More Related Content

Watch kit pitfalls. developing iOS app for Dribbble.

  • 1. WatchKit Pitfalls Developing iOS App for Dribbble Zgonik Vova
  • 2. Register your application Website URL Callback URL Client ID Client Secret Client Access Token https://dribbble.com/account/applications/new
  • 3. OAuth2 solutions NXOauth2Client GTMOAuth2 Detailed error handling Block callbacks No response body on auth error NSNotificationCenter
  • 4. Dribbble API understanding of HTTP response codes 422 Unprocessable Entity 400 Bad request 500 Internal server error 403 Operation is forbidden upload shot or attachment without mimeType follow more than 1800 followers follow own userId incorrect parameter name upload limit: - 48 shots per month - 5 shots per day access denied (canUplodShot = NO) 429 Too many requests 304 Content not modified 404 Not found 204 No content API restrictions: 60 requests per minute 10000 requests per day no like shot, like comment transaction entry found no following transaction entry 束A follows B損 found presence of transaction entry for user 束A follows user B損 response on delete request for: like comment, like shot if the resource has not changed in conditional request with parameter If-Modified-Since POST incorrect JSON
  • 6. Requests Rate Limiting low-priority check if like shot check if follow user 60 per minute 10000 per day high-priority account request switch & load category of shots like shot follow user
  • 8. watchOS App WatchKit App WatchKit app Target Storyboard Resources WatchKit Extension WatchKit extension target WatchKit code and Resources WatchKit App IOS App iOS app target iOS Code WatchKit Extension WatchKit app stores on watch device and consist of storyboard and static resources (images, fonts) WatchKit Extension stores on iPhone and consist of source and resources all source executes on iPhone, without iPhone Watch app wont launch
  • 9. NOT SURE OF WHAT IS GOING ON HERE
  • 10. iPhone Extension Communication Glance Notification WKInterfaceController Apple Watch WatchKit App Storyboard Resources WatchKit Extension Code Resources WatchKitWatchKit
  • 11. WatchKit Launch Flow Launch WatchKit APP Load initial interface controller Initialize UI Display UI Storyboard Interface controller init willActivate user launches app on watch watchKit finds initial controller in storyboard and notifies iPhone watchKit Extension should be launched and specified class of controller is instantinated WatchKit Extension
  • 13. Glance no interactive items: buttons, switches no vertical scrolling San Francisco system font only Apple doesnt recommend use maps and tables
  • 14. Notification short look no interactive items: buttons, switches, sliders allow different typefaces of system font allow change tint color with app Name
  • 15. Notification long look system stuff application content action defined in watch app two types activation mode: background & foreground
  • 16. openParentApplication:reply: App Groups Darwin-notification Handoff WatchKit Extension and App Communication Communication model classes, web services, credentials restricted API: ! any API marked with NS_EXTENSION_UNAVAILABLE ! calls to UIApplication +sharedApplication ! access the camera or microphone on an iOS device ! receive data using AirDrop Sharing code
  • 17. openParentApplication API on watch App [WKInterfaceController openParentApplication:reply:] API on main application: implement (:handleWatchKitExtensionRequest:reply:) main app launches in background error handling available - slower than other methods + API calls time increases - objects should conform <NSCoding>
  • 18. App Groups com.apple.security.application-groups entitlement initWithSuiteName: (NSUserDefaults) containerURLForSecurityApplicationGroupIdentifier: (NSFileManager) - main app cant notify watch about new data
  • 19. Darwin-notifications Exchange messages between processes in iOS by means of Darwin-notifications pod MMWormHole Sending process Notification notifyd routines allow processes to exchange stateless notification events process 1 process 2 process 3 Client processesnotification is just a signal it can't transport any data apart from the notification identifier
  • 20. Handoff NSUserActivity in main apps Info.plist perform updateUserActivity:userInfo:webpageURL: in WKInterfaceController handle activity event in AppDelegate: - application:willContinueUserActivity - application:continueUserActivity:restorationHandler
  • 22. ApiClient AppDelegate ShotsViewController WKInterfaceControllerWatch App Main App Core structure ShotsController Data source Networking ShotBucketCore Framework App Models Oauth2Clients Api Clients ActionManager
  • 24. . . . . . . . . . Gallery on WatchKit reloadRootControllersWithNames: contexts: swipe Initial Interface Controller swipe 12:0012-0012-00 12-00 Load more Modal controller 12-00Close ContentContent More pictures?
  • 25. Page-based Controller Life Cycle Changes
  • 27. Smart personalized notifications without backend Background fetch Conditional request Last-Modified: Sat, 22 Feb 2014 17:10:33 GMT HTTP/1.1 304 Not ModifiedHTTP/1.1 200 OK Local notification No action
  • 28. BG Fetch issues - [UIApplication performFetchWithCompletionHandler:] UIBackgroundFetchResult UIBackgroundFetchResultNewData UIBackgroundFetchResultNoData UIBackgroundFetchResultFailed