2016 年 6 月,WWDC2016 发布了 iOS10,重磅介绍了升级后的 iMessage,其中,最值得一提的就是 iMessage 内的应用。通过这个特性,用户可以在 iMessage 聊天窗口里玩游戏,效果和后来的微信群聊里的小游戏卡片一样(只是要下载)。
在 Signing &
Capabilities
新建 On Demand Install Capable
AppClip.entitlements
属性列表文件,默认包含一个 key
:com.apple.developer.parent-application-identifiers
,值为包含原始 target
的 identifier
的数组,demo 的 identifier
为 com.ifanr.BookShelf
。
BooKShelfClip
的默认 identifier
以原始 target identifier
作为前缀,后面加上 .Clip
。在 BookShelfClip Target
中 identifier
为 com.ifanr.BookShelf.Clip
。
首先,在 BookShelfClip 目录下的 SceneDelete.swift 文件的方法 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
中将 HomeView
作为初始启动界面,代码如下:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let contentView = HomeView()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
HomeView
从哪里来的呢?这就是 App Clip 开发上的便利:可以不写代码。通过和原始 Target: BookShelf 共享文件,BookShelfClip 可以直接使用 BookShelf 中已经写好的 HomeView
,如下图:
集成知晓云后端云服务 SDK 的全功能 App Clip;
通过 URL、扫码等方式打开 App Clip 的配置、实际效果。
▽ 点击阅读全文,让你的小程序开发快人一步