Links

Today Extensions - Widgets at a glance

Extensions in iOS are delivered as a part of your app in Extension Container. They are purpose built binaries which can be accessed via Apple framework code. They don't provide app to app inter-process communication.

Extension Points are the frameworks exposed to the both Widget and its App to provide an information exchange architecture. Extensions can only communicate with there hosting app.
Today Extensions also known as Notification Center Extensions or Widgets are view controllers (it follows all lifecycle methods).

From performance perspective;
  • Cache fetched data
  • Load cached data for seamless transitions
  • Should complete heavy operations in background

From layout perspective;
  • The notification Center itself set frames of the base view
  • Its recommended to use Auto-layout
  • We can resize the widget height based on our needs
  • We can manage the Animations and Transitions while changing view, they will work in parallel of system transitions
  • Widget can receive the size change notifications and perform required changes based on that

Basic steps to create a new widget for your app;
  1. In your existing app, "Add a new target"
  2. There is a new "Application Extension" option in XCode 6+
  3. Select "Today Extension"
  4. Create a "UIViewController" attached to storyboard
  5. Code the content of your view controller just like you code it for your app, this might be any kinda listing or detailed info, whatsoever..
  6. We can provide widget height in "-(void)awakeFromNib" by setting [self setPreferredContentSize:---]
  7. We can use "-(void)widgetPerformUpdateWithCompletionHandler:" to get notified for our widget update and perform essential data update. NCWidgetProviding provides mechanism to get informed about widget.
  8. Optionally or Based on app requirement, we can add a link in the widget to our app so that user can see detailed information
  9. We can access the host app with [self extensionContext], by using the same we can perform [.. openURL] and open the app with its registered URL scheme (e.g; sampleapp://)

Post a Comment