watch kit pitfalls. developing ios app for dribbble
TRANSCRIPT
![Page 1: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/1.jpg)
WatchKit Pitfalls
Developing iOS App for Dribbble
Zgonik Vova
![Page 2: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/2.jpg)
Register your application
• Website URL
• Callback URL
• Client ID
• Client Secret
• Client Access Tokenhttps://dribbble.com/account/applications/new
![Page 3: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/3.jpg)
OAuth2 solutions
NXOauth2Client GTMOAuth2
• Detailed error handling
• Block callbacks
• No response body on auth
error
• NSNotificationCenter
![Page 4: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/4.jpg)
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)
429Too many requests
304Content not
modified
404Not found
204No 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
![Page 5: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/5.jpg)
![Page 6: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/6.jpg)
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
![Page 7: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/7.jpg)
Apple Watch
![Page 8: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/8.jpg)
watchOS App
WatchKit App
WatchKit app Target
Storyboard
Resources
WatchKit Extension
WatchKit extension target
WatchKit codeand 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 won’t launch
![Page 9: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/9.jpg)
NOT SURE OF WHAT IS GOING ON HERE
![Page 10: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/10.jpg)
iPhone
Extension Communication
Glance
Notification
WKInterfaceControll
er
Apple Watch
WatchKit App
Storyboard
Resources
WatchKit Extension
Code
Resources
WatchKitWatchKit
![Page 11: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/11.jpg)
WatchKit Launch Flow
Launch WatchKit
APP
Load initialinterface 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
![Page 12: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/12.jpg)
![Page 13: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/13.jpg)
Glance
• no interactive items: buttons, switches
• no vertical scrolling
• San Francisco system font only
• Apple doesn’t recommend use maps and
tables
![Page 14: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/14.jpg)
Notification short look
• no interactive items: buttons, switches,
sliders
• allow different typefaces of system font
• allow change tint color with app Name
![Page 15: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/15.jpg)
Notification long looksystem stuff
application content
action definedin watch app
two types activation mode:
background & foreground
![Page 16: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/16.jpg)
• 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
![Page 17: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/17.jpg)
openParentApplicationAPI 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>
![Page 18: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/18.jpg)
App Groups
• com.apple.security.application-groups entitlement
• initWithSuiteName: (NSUserDefaults)
• containerURLForSecurityApplicationGroupIdentifier: (NSFileManager)
- main app can’t notify watch about new data
![Page 19: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/19.jpg)
Darwin-notifications
Exchange messages between processes in iOS by means of Darwin-notifications
pod ‘MMWormHole’
Sending processNotification
notifyd
routines allow processes to exchange stateless
notification events
process 1
process 2
process 3
Client processesnotification is just a signalit can't transport any data apart from
the notification identifier
![Page 20: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/20.jpg)
Handoff
• NSUserActivity in main app’s Info.plist
• perform updateUserActivity:userInfo:webpageURL: in
WKInterfaceController
• handle activity event in AppDelegate:
- application:willContinueUserActivity
- application:continueUserActivity:restorationHandler
![Page 21: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/21.jpg)
Shot Bucket App
![Page 22: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/22.jpg)
ApiClient
AppDelegate
ShotsViewController
WKInterfaceControllerWatch App
Main App
Core structure
ShotsControllerData source
Networking
ShotBucketCore Framework
App ModelsOauth2Clients
Api ClientsActionManager
![Page 23: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/23.jpg)
Gallery on WatchKit
![Page 24: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/24.jpg)
. . . . . . . . .
Gallery on WatchKit
reloadRootControllersWithNames:contexts:
swipe
InitialInterfaceController
swipe
12:0012-0012-00
12-00
Load more
Modal controller
12-00Close
ContentContent
More pictures?
![Page 25: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/25.jpg)
Page-based Controller Life Cycle Changes
![Page 26: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/26.jpg)
![Page 27: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/27.jpg)
Smart personalized notifications without backend
Background fetch
Conditional requestLast-Modified: Sat, 22 Feb 2014 17:10:33 GMT
HTTP/1.1 304 Not ModifiedHTTP/1.1 200 OK
Local notification No action
![Page 28: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/28.jpg)
BG Fetch issues
- [UIApplication performFetchWithCompletionHandler:]
UIBackgroundFetchResult
• UIBackgroundFetchResultNewData
• UIBackgroundFetchResultNoData
• UIBackgroundFetchResultFailed
![Page 29: Watch kit pitfalls. developing iOS app for Dribbble](https://reader035.vdocuments.mx/reader035/viewer/2022081419/55cbab96bb61ebb6088b45fd/html5/thumbnails/29.jpg)