iOS App Extension 介绍

应用扩展介绍

App Extension是iOS8推出来的一个新特性,iOS9,iOS10中相继推出了许多新的扩展点。

应用扩展程序可以让我们自定义功能和内容扩展到应用程序之外,并在用户与其他应用程序或系统交互时提供给用户使用。

我们可以创建一个应用程序扩展来启用特定的任务。例如,为了让用户将消息通过Web浏览器向发布到社交服务,可以提供一个共享扩展。或者,为了让用户赶上他们喜欢的团队,可以提供一个在通知中心显示当前运动成绩的今日小部件。我们甚至可以创建一个应用程序扩展,提供用户可以代替ios系统键盘使用的自定义键盘。

举个最简单的示例,如《今日头条》

今日扩展

红框部分就是一个名叫Today extensions (今日扩展)的应用,它可以将应用的最新消息展示给用户,更多的如:

更多

有系统的,也有应用添加的,我们可以在不打开应用的情况下,看到应用的部分消息,也可以通过应用扩展快速打开到对应模块

iOS8中的扩展

  • Today extensions (今日扩展)

Today extension就是我们上面所看到的一种扩展。这个扩展的作用很简单,能够让用户更快速方便的看到app最及时的信息,比如中国移动的流量显示,用户不用再每次打开移动的app去查看流量,而是直接在通知中心,甚至锁屏界面就可以查看

  • Share extensions

分享扩展可以使用户在不同的app之间分享内容。这个功能在iOS5的时候就已经出来了,但是仅限于相册分享图片到tweeter,iOS6中可以分享到Facebook,但是现在,我们可以写分享扩展来分享到我们自己的服务器。
比如我有一张相册中的图片想要通过微信发送给我的朋友,如果没有分享扩展,我只能打开微信与朋友聊天的界面 -> 选择发送图片 -> 到相册中选择图片 -> 然后发送。但是有了分享扩展,我可以直接在相册中点击分享按钮,点击微信,选择好友后,直接分享给好友,而不用打开微信来发送了。

分享扩展

分享扩展

  • Action extensions

行为扩展这个名字有点难理解,它可以让用户查看和改变一个app中的某些内容,而不用离开这个app。
比如我在知乎看帖子,碰到一个不会的单词,咋办?如果没有应用扩展,我只能切换到有道词典,输入这个单词来查看,然后再切回知乎,但是现在有了有道词典的行为扩展,我只要复制这个单词,点击共享,在下面 选择有道词典的扩展,就可以不用打开有道词典这个app了,而直接能够显示出翻译结果。

行为扩展

  • Photo Editing extensions

图片编辑扩展可以使用户直接在iphone的手机相册中利用第三方图片编辑软件提供的扩展来编辑图片。
比如我现在有一张自拍照,想要编辑一下。如果没有图片编辑扩展的话,我只能打开美图秀秀之类的图片编辑软件,导入图片,编辑保存。有了图片编辑扩展之后,我只需要在系统相册中找到这张图片,点击分享按钮调出菜单,选择第三方的图片编辑扩展,就可以直接进入编辑界面,编辑完直接保存,而不用再打开这个图片编辑软件导入图片来进行编辑了。但是这个扩展仅限于在自带的相册中进行编辑,而不是所有app中图片都可以。

  • Document Provider extensions

文件提供者扩展会显示一个文件选择视图给用户,这些选择项可以让用户导入,导出,或者用其他app来打开这个文件。

  • Custom Keyboard extensions

自定义键盘扩展可以让开发者创建系统键盘之外的自定义键盘,比如搜狗输入法。

iOS9中的扩展点

网络相关的扩展点,很多的VPN,网络工具等软件都是基于这三个网络扩展点。

  • Packet Tunnel Provider extension :

可以利用这个扩展点来实现客户端的自定义VPN隧道协议。

  • App Proxy Provider extension:

利用这个扩展点可以实现客户端自定义透明网络代理协议。

  • Filter Data Provider and the Filter Control Provider extension:

利用这个扩展点可以实现动态的,基于设备的网络内容过滤。

Safari相关的扩展点,很多的Safari广告屏蔽软件都是基于下面这两个扩展点

  • Shared Links extension

利用这个扩展点可以使用户在Safari的分享链接里面看到app的内容

  • Content Blocking extension :

利用这个扩展点,可以给Safari提供一个拦截列表,在这个拦截列表里面你可以描述当用户再使用Safari的时候你想要拦截的内容。

  • Index Maintenance extension:

利用这个扩展点实现在不重启app的情况下对app内的数据重新建立索引。

  • Audio Unit extension:

这个扩展点允许你的应用提供乐器、声音效果、声音发生器等,它们可以在GarageBand、Logic这类AU宿主应用里使用。扩展点还可以将完整的音频插件模式搬到iOS上并允许你在App Store里销售Audio Units插件

iOS10中的扩展点

  • Call Directory extension
  • Intents extension
  • Intents UI extension
  • Messages extension
  • Notification Content extension

针对通知内容的扩展,你可以自定义通知内容。

  • Notification Service extension

可以优化通知到达率。

  • Sticker Pack extension:

iOS10中又新增了6个扩展点,这些扩展点的加入,使得iOS10功能更加强大。iOS 10 应用扩展的剧变,对你的 iPhone 有什么影响

App Extension的工作原理,生命周期

工作原理

应用扩展本身不是一个app,而只是对于某个app内容和功能的扩展,所以不能够单独的上架AppStore,而是跟随着你的app一起打包,这个包含应用扩展一起打包的app就叫做 container app(容器app)。虽然应用扩展是包含在 container app 中打包的,但是运行时它并不是跟你的app在同一个进程上面,而且有可能同一个 app extension 会同时运行在不同的进程,因为有可能同时有几个程序都打开了这个app extension,这个用来打开某个 app Extension 的应用就叫做 host app(宿主应用)。

当一个应用扩展在运行的时候,它能够直接和 host app 进行通信,但是一般无法和 container app 进行通信,甚至经常在应用扩展运行的时候,你的 container app可能都没有打开。比如对于微信分享扩展来说,如果我要从一个新闻软件分享一篇新闻到微信,通过微信的分享扩展,我可以不用打开微信,甚至微信的进程都没有启动,我只要在新闻软件中直接通过扩展分享到微信就可以了,下次打开微信就可以看到。如果一个app extension 一定要和 container app 进行通信的时候,可以利用 opeURL() 或者是 数据共享 (本文只是概念基础介绍,后面会有单独的文章来介绍如何实现)。

生命周期

因为应用扩展不是一个完整,独立的app,所以它的生命周期跟我们正常的app并不一样。应用扩展是在用户从其它软件的界面或者系统界面打开它的时候启动,一般都是 host app 发出一个 request,app extension 对应的响应这个请求,在 response 结束之后,app extension 的生命周期也就终止了。

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Title: iOS 8 App Development Essentials Author: Neil Smyth Length: 824 pages Edition: 1 Language: English Publisher: CreateSpace Independent Publishing Platform Publication Date: 2014-12-16 ISBN-10: 1505586410 ISBN-13: 9781505586411 iOS 8 App Development Essentials is the latest edition of this popular book series and has now been fully updated for the Swift programming language, the iOS 8 SDK and Xcode 6. Beginning with the basics, this book provides an outline of the steps necessary to set up an iOS development environment. An introduction to the architecture of iOS 8 and programming in Swift is provided, followed by an in-depth look at the design of iOS applications and user interfaces. More advanced topics such as file handling, database management, in-app purchases, graphics drawing and animation are also covered, as are touch screen handling, gesture recognition, multitasking, iAds integration, location management, local notifications, camera access and video and audio playback support. Other features are also covered including Auto Layout, Twitter and Facebook integration, App Store hosted in-app purchase content, collection views, Sprite Kit-based game development, local map search and user interface animation using UIKit dynamics. The key new features of the iOS 8 SDK and Xcode 6 are also covered, including Swift playgrounds, universal user interface design using size classes, app extensions, Interface Builder Live Views, embedded frameworks, CloudKit data storage and TouchID authentication. The aim of this book is to teach the range of skills necessary to build apps for iOS 8. iOS 8 App Development Essentials takes a modular approach to the subject of iOS 8 application development for both the iPhone and iPad, with each chapter covering a self contained topic area consisting of detailed explanations, examples and step-by-step tutorials. This makes the book both an easy to follow learning aid and an excellent reference resource. Table of Contents Chapter 1. Start Here Chapter 2. Joining the Apple iOS Developer Program Chapter 3. Installing Xcode 6 and the iOS 8 SDK Chapter 4. A Guided Tour of Xcode 6 Chapter 5. Testing Apps on iOS 8 Devices with Xcode 6 Chapter 6. An Introduction to Swift Playgrounds Chapter 7. Swift Data Types, Constants and Variables Chapter 8. Swift Operators and Expressions Chapter 9. Swift Flow Control Chapter 10. The Swift Switch Statement Chapter 11. An Overview of Swift Functions and Closures Chapter 12. The Basics of Object Oriented Programming in Swift Chapter 13. An Introduction to Swift Inheritance Chapter 14. Working with Array and Dictionary Collections in Swift Chapter 15. The iOS 8 Application and Development Architecture Chapter 16. Creating an Interactive iOS 8 App Chapter 17. Understanding iOS 8 Views, Windows and the View Hierarchy Chapter 18. An Introduction to Auto Layout in iOS 8 Chapter 19. Working with iOS 8 Auto Layout Constraints in Interface Builder Chapter 20. An iOS 8 Auto Layout Example Chapter 21. Implementing iOS 8 Auto Layout Constraints in Code Chapter 22. Implementing Cross-Hierarchy Auto Layout Constraints in iOS 8 Chapter 23. Understanding the iOS 8 Auto Layout Visual Format Language Chapter 24. Using Size Classes to Design Universal iOS User Interfaces Chapter 25. Using Storyboards in Xcode 6 Chapter 26. Using Xcode 6 Storyboards to Create an iOS 8 Tab Bar Application Chapter 27. An Overview of iOS 8 Table Views and Xcode 6 Storyboards Chapter 28. Using Xcode 6 Storyboards to Build Dynamic TableViews with Prototype Table View Cells Chapter 29. Implementing iOS 8 TableView Navigation using Storyboards in Xcode 6 Chapter 30. An iOS 8 Split View Master-Detail Example Chapter 31. Implementing a Page based iOS 8 Application using UIPageViewController Chapter 32. An Example iOS 8 UIPageViewController Application Chapter 33. Working with Directories in Swift on iOS 8 Chapter 34. Working with Files in Swift on iOS 8 Chapter 35. iOS 8 Directory Handling and File I/O in Swift – A Worked Example Chapter 36. Preparing an iOS 8 App to use iCloud Storage Chapter 37. Managing Files using the iOS 8 UIDocument Class Chapter 38. Using iCloud Storage in an iOS 8 Application Chapter 39. Synchronizing iOS 8 Key-Value Data using iCloud Chapter 40. iOS 8 Data Persistence using Archiving Chapter 41. iOS 8 Database Implementation using SQLite Chapter 42. An Example SQLite based iOS 8 Application using Swift and FMDB Chapter 43. Working with iOS 8 Databases using Core Data Chapter 44. An iOS 8 Core Data Tutorial Chapter 45. An Introduction to CloudKit Data Storage on iOS 8 Chapter 46. An iOS 8 CloudKit Example Chapter 47. An iOS 8 CloudKit Subscription Example Chapter 48. An Overview of iOS 8 Multitouch, Taps and Gestures Chapter 49. An Example iOS 8 Touch, Multitouch and Tap Application Chapter 50. Detecting iOS 8 Touch Screen Gesture Motions Chapter 51. Identifying Gestures using iOS 8 Gesture Recognizers Chapter 52. An iOS 8 Gesture Recognition Tutorial Chapter 53. Implementing TouchID Authentication in iOS 8 Apps Chapter 54. An Overview of iOS 8 Collection View and Flow Layout Chapter 55. An iOS 8 Storyboard-based Collection View Tutorial Chapter 56. Subclassing and Extending the iOS 8 Collection View Flow Layout Chapter 57. Drawing iOS 8 2D Graphics with Core Graphics Chapter 58. Interface Builder Live Views and iOS 8 Embedded Frameworks Chapter 59. An iOS 8 Graphics Tutorial using Core Graphics and Core Image Chapter 60. Basic iOS 8 Animation using Core Animation Chapter 61. iOS 8 UIKit Dynamics – An Overview Chapter 62. An iOS 8 UIKit Dynamics Tutorial Chapter 63. An Introduction to iOS 8 Sprite Kit Programming Chapter 64. An iOS 8 Sprite Kit Level Editor Game Tutorial Chapter 65. An iOS 8 Sprite Kit Collision Handling Tutorial Chapter 66. An iOS 8 Sprite Kit Particle Emitter Tutorial Chapter 67. Integrating iAds into an iOS 8 App Chapter 68. iOS 8 Multitasking, Background Transfer Service and Fetching Chapter 69. Scheduling iOS 8 Local Notifications Chapter 70. An Overview of iOS 8 Application State Preservation and Restoration Chapter 71. An iOS 8 State Preservation and Restoration Tutorial Chapter 72. Integrating Maps into iOS 8 Applications using MKMapItem Chapter 73. An Example iOS 8 MKMapItem Application Chapter 74. Getting Location Information using the iOS 8 Core Location Framework Chapter 75. An Example iOS 8 Location Application Chapter 76. Working with Maps on iOS 8 with MapKit and the MKMapView Class Chapter 77. Working with MapKit Local Search in iOS 8 Chapter 78. Using MKDirections to get iOS 8 Map Directions and Routes Chapter 79. An Introduction to Extensions in iOS 8 Chapter 80. An iOS 8 Today Extension Widget Tutorial Chapter 81. Creating an iOS 8 Photo Editing Extension Chapter 82. Creating an iOS 8 Action Extension Chapter 83. Receiving Data from an iOS 8 Action Extension Chapter 84. Using iOS 8 Event Kit to Create Date and Location Based Reminders Chapter 85. Accessing the iOS 8 Camera and Photo Library Chapter 86. An Example iOS 8 Camera Application Chapter 87. iOS 8 Video Playback using AVPlayer and AVPlayerViewController Chapter 88. Playing Audio on iOS 8 using AVAudioPlayer Chapter 89. Recording Audio on iOS 8 with AVAudioRecorder Chapter 90. Integrating Twitter and Facebook into iOS 8 Applications Chapter 91. An iOS 8 Facebook Integration Tutorial using UIActivityViewController Chapter 92. iOS 8 Facebook and Twitter Integration using SLRequest Chapter 93. An iOS 8 Twitter Integration Tutorial using SLRequest Chapter 94. Making Store Purchases with the SKStoreProductViewController Class Chapter 95. Building In-App Purchasing into iOS 8 Applications Chapter 96. Preparing an iOS 8 Application for In-App Purchases Chapter 97. An iOS 8 In-App Purchase Tutorial Chapter 98. Configuring and Creating App Store Hosted Content for iOS 8 In-App Purchases Chapter 99. Preparing and Submitting an iOS 8 Application to the App Store
iOS 10 App Development Essentials: Learn to Develop iOS 10 Apps with Xcode 8 and Swift 3 Author: Neil Smyth Length: 816 pages Edition: 1 Language: English Publisher: CreateSpace Independent Publishing Platform Publication Date: 2016-10-21 ISBN-10: 1539675033 ISBN-13: 9781539675037 Table of Contents 1. Start Here 2. Joining the Apple Developer Program 3. Installing Xcode 8 and the iOS 10 SDK 4. A Guided Tour of Xcode 8 5. An Introduction to Xcode 8 Playgrounds 6. Swift Data Types, Constants and Variables 7. Swift Operators and Expressions 8. Swift Flow Control 9. The Swift Switch Statement 10. An Overview of Swift 3 Functions, Methods and Closures 11. The Basics of Object Oriented Programming in Swift 12. An Introduction to Swift Subclassing and Extensions 13. Working with Array and Dictionary Collections in Swift 14. Understanding Error Handling in Swift 3 15. The iOS 10-Application and Development Architecture 16. Creating an Interactive iOS 10 App 17. Understanding iOS 10 Views, Windows and the View Hierarchy 18. An Introduction to Auto Layout in iOS 10 19. Working with iOS 10 Auto Layout Constraints in Interface Builder 20. An iOS 10 Auto Layout Example 21. Implementing iOS 10 Auto Layout Constraints in Code 22. Implementing Cross-Hierarchy Auto Layout Constraints in iOS 10 23. Understanding the iOS 10 Auto Layout Visual Format Language 24. Using Trait Variations to Design Adaptive iOS 10 User Interfaces 25. Using Storyboards in Xcode 8 26. Organizing Scenes over Multiple Storyboard Files 27. Using Xcode 8 Storyboards to Create an iOS 10 Tab Bar Application 28. An Overview of iOS 10 Table Views and Xcode 8 Storyboards 29. Using Xcode 8 Storyboards to Build Dynamic TableViews 30. Implementing iOS 10 TableView Navigation using Storyboards in Xcode 8 31. Working with the iOS 10 Stack View Class 32. An iOS 10 Stack View Tutorial 33. An iOS 10 Split View Master-Detail Example 34. A Guide to Multitasking in iOS 10 35. An iOS 10 Multitasking Example 36. Working with Directories in Swift on iOS 10 37. Working with Files in Swift on iOS 10 38. iOS 10 Directory Handling and File I/O in Swift – A Worked Example 39. Preparing an iOS 10 App to use iCloud Storage 40. Managing Files using the iOS 10 UIDocument Class 41. Using iCloud Storage in an iOS 10 Application 42. Synchronizing iOS 10 Key-Value Data using iCloud 43. iOS 10 Database Implementation using SQLite 44. An Example SQLite based iOS 10 Application using Swift and FMDB 45. Working with iOS 10 Databases using Core Data 46. An iOS 10 Core Data Tutorial 47. An Introduction to CloudKit Data Storage on iOS 10 48. An Introduction to CloudKit Sharing 49. An iOS 10 CloudKit Example 50. An iOS 10 CloudKit Subscription Example 51. An iOS 10 CloudKit Sharing Example 52. An Overview of iOS 10 Multitouch, Taps and Gestures 53. An Example iOS 10 Touch, Multitouch and Tap Application 54. Detecting iOS 10 Touch Screen Gesture Motions 55. Identifying Gestures using iOS 10 Gesture Recognizers 56. An iOS 10 Gesture Recognition Tutorial 57. A 3D Touch Force Handling Tutorial 58. An iOS 10 3D Touch Quick Actions Tutorial 59. An iOS 10 3D Touch Peek and Pop Tutorial 60. Implementing TouchID Authentication in iOS 10 Apps 61. Drawing iOS 10 2D Graphics with Core Graphics 62. Interface Builder Live Views and iOS 10 Embedded Frameworks 63. An iOS 10 Graphics Tutorial using Core Graphics and Core Image 64. iOS 10 Animation using UIViewPropertyAnimator 65. iOS 10 UIKit Dynamics – An Overview 66. An iOS 10 UIKit Dynamics Tutorial 67. An Introduction to iOS 10 Sprite Kit Programming 68. An iOS 10 Sprite Kit Level Editor Game Tutorial 69. An iOS 10 Sprite Kit Collision Handling Tutorial 70. An iOS 10 Sprite Kit Particle Emitter Tutorial 71. iOS 10 Multitasking, Background Transfer Service and Fetching 72. An iOS 10 Local Notification Tutorial 73. An Overview of iOS 10 Application State Preservation and Restoration 74. An iOS 10 State Preservation and Restoration Tutorial 75. Integrating Maps into iOS 10 Applications using MKMapItem 76. An Example iOS 10 MKMapItem Application 77. Getting Location Information using the iOS 10 Core Location Framework 78. An Example iOS 10 Location Application 79. Working with Maps on iOS 10 with MapKit and the MKMapView Class 80. Working with MapKit Local Search in iOS 10 81. Using MKDirections to get iOS 10 Map Directions and Routes 82. An iOS 10 MapKit Flyover Tutorial 83. An Introduction to Extensions in iOS 10 84. An iOS 10 Today Extension Widget Tutorial 85. Creating an iOS 10 Photo Editing Extension 86. Creating an iOS 10 Action Extension 87. Receiving Data from an iOS 10 Action Extension 88. An Introduction to Building iOS 10 Message Apps 89. An iOS 10 Interactive Message App Tutorial 90. Using iOS 10 Event Kit to Create Date and Location Based Reminders 91. Accessing the iOS 10 Camera and Photo Library 92. An Example iOS 10 Camera Application 93. iOS 10 Video Playback using AVPlayer and AVPlayerViewController 94. An iOS 10 Multitasking Picture in Picture Tutorial 95. Playing Audio on iOS 10 using AVAudioPlayer 96. Recording Audio on iOS 10 with AVAudioRecorder 97. An iOS 10 Speech Recognition Tutorial 98. An iOS 10 Real-Time Speech Recognition Tutorial 99. An Introduction to SiriKit 100. An iOS 10 Example SiriKit Messaging Extension 101. An iOS 10 SiriKit Photo Search Tutorial 102. Integrating Twitter and Facebook into iOS 10 Applications 103. An iOS 10 Social Media Integration Tutorial using UIActivityViewController 104. iOS 10 Facebook and Twitter Integration using SLRequest 105. An iOS 10 Twitter Integration Tutorial using SLRequest 106. Making Store Purchases with the SKStoreProductViewController Class 107. Building In-App Purchasing into iOS 10 Applications 108. Preparing an iOS 10 Application for In-App Purchases 109. An iOS 10 In-App Purchase Tutorial 110. Configuring and Creating App Store Hosted Content for iOS 10 In-App Purchases 111. Preparing and Submitting an iOS 10 Application to the App Store

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值