跳至主要内容

App Clips

 参考链接

https://www.jianshu.com/p/21af85107a34

https://developer.apple.com/documentation/app_clips?language=objc

https://developer.apple.com/documentation/app_clips/configuring_your_app_clip_s_launch_experience?language=objc

https://developer.apple.com/documentation/app_clips/making_data_available_to_the_app_clip_s_corresponding_app?language=objc


3.App Clips流程使用

3.1启动流程
  • 从用户以各种方式与轻 App Clips交互开始,直到用户切换到完整 App。
  • 如果存在主App那么App Clips不会被调起、如果不存在、那么唤起App Clips、同时可以引导下载主App。


    image.png
3.2 调用场景
  • 通过NFC扫描来唤起
  • 通过点击Sari提供的基于地理位置的推荐
  • 在地图App上点击指定的链接
  • 点击网页上的智能推荐横幅
  • 通过Messages App分享的链接
  • 二维码扫描进入

3.3 App Clips技术限制

App Clip 仅限应用于特定场景,即尽可能快地完成一个任务,即用即走。你可以把它看作主 app 的核心功能应用,对于复杂的任务应该在其对应的主 app 完成,因此某些功能被禁止在 App Clip 中使用。

  • 安装包大小 10M 以内
    当弹出 App Clip Card 时会立即下载 App Clip,安装包大小的限制保证了用户体验——当用户打开 App Clip 时大概率已经下载好。
  • 不能使用指定 Framework
    Assets Library, CallKit, CareKit, CloudKit, Contacts, Contacts UI, Core Motion, File Provider, File Provider UI, HealthKit, HomeKit, Media, Player, Messages, Message UI, PhotoKit, ResearchKit, SensorKit, Speech
    以上 Framework 不能在 AppClip 使用,若使用了在编译时不会报错,而是在运行时报错或者返回错误的结果。
  • 用户隐私相关操作
    1.不能跟踪用户信息,也不能通过 identifierForVendor 来获取用户唯一标识。
    2.不能持续地获取用户位置,每次使用位置需要请求用户授权,次日凌晨 4:00,会自动关闭授权。再次使用位置时,需要用户重新授权。
    3.只允许 App Clip 和其对应的主 app 通信,不允许和其他 app 进行通信,这就导致微信登录分享支付等功能在 App Clip 里使用不了。
    4.不能访问苹果音乐、多媒体,通讯录,文件,运动健康,相册等数据。
  • 其他复杂任务
    1.后台活动:网络请求、位置更新等
    2.蓝牙连接
    3.App extensions
    4.URL schemes
    5.内购(In-app purchases)(区别苹果支付 Apple Pay,在 App Clip 是能够使用苹果支付的)

4.开发流程

4.1.证书配置 : bundle iD 、 App Group配置
4.2.创建Extention :App Clips
4.3.配置权限App Clips可访问权限,Info.plist配置
4.4.开发方式

  • 通过 App Group 将数据从App Clips 传输到完整 App、
  • 通过 SKOverlay 从轻 App 跳转到完整 App
  • macros宏:复用主App代码
#ifdef CLIPS
    xxxx
#endif

4.5.测试调用 URL 具体步骤如下:
1.点击 Product -> 编辑轻 App 对应的 Scheme
2.添加 Environment variable _XCAppClipURL 这个键值来模拟调用 URL
3.在轻 App 对应 target 运行轻 App 的 scheme。NSUserActivity 获取这个值。

5.调用验证

App Clips 在通用设置->轻App查看(30天自动清除)

5.1 安装方式:
  • 使用 Xcode 构建并运行 App Clips
  • 使用 Xcode 中 Archive 功能为App Clips 创建 ipa 文件,在设备上安装
  • 通过 TestFlight 向用户推送App Clips
5.2 调用方式:
  • 轻点 NFC 标签
  • iOS 系统相机二维码扫描
5.3 开发测试步骤:

1.真机运行App Clips项目(iOS 14系统),执行对应Extention Target
2.通用设置->开发者>-App Clips Testing->配置URL、Bundle ID 和卡片类型(Open、View、Play)
3.配置URL生成二维码->iPhone 扫码打开-> 唤起App Clips


Share Data Between the App Clip and the App

Your App Clip can make its data accessible to its corresponding app by storing data in a shared container. The full app can then access this data when it replaces the App Clip, providing a positive user experience.

To store data in a shared container:

  1. Add the App Groups capability to targets for both the App Clip and the full app.

  2. For both targets, add the same app group to the capability; for example, group.exampleApp.appClipMigration.

  3. In your App Clip’s code, obtain the URL for the shared container using containerURLForSecurityApplicationGroupIdentifier: and store data using the URL; for example, by using writeToURL:atomically:encoding:error:.

  4. In your app’s code, use the same function to obtain the URL of the shared container and access its content; for example, by using initWithContentsOfURL:.

In addition to a shared container, the App Clip can also store information in a shared NSUserDefaults instance that’s accessible to the full app. The following code uses the configured app group to create the shared UserDefaults instance and store a string:

guard let sharedUserDefaults = UserDefaults(suiteName: "group.exampleApp.appClipMigration") else {    // Error handling}sharedUserDefaults.set("A sample string", forKey: "sharedText")

When users install the full app, it can access the shared user defaults. For example, to access the string stored in the previous code:

guard let sharedUserDefaults = UserDefaults(suiteName: "group.exampleApp.appClipDataMigration") else {    // Error handling}guard let migratedData = sharedUserDefaults.string(forKey: "sharedText") else { return }

To preserve user privacy across apps and App Clips, an App Clip can only share its data with its corresponding app. In addition, you can’t make information the App Clip stores in the keychain accessible to its corresponding full app.


评论

此博客中的热门博文

Resolving errSecInternalComponent errors during code signing

原文链接 One code signing issue I commonly see, both here on DevForums and in my Day Job™ with DTS, is that the codesign command fails with errSecInternalComponent. This issue crops up in a wide variety of circumstances and the correct fix depends on the specific problem. This post is my attempt to clarify the potential causes of this error and help folks resolve it. If you have any questions or comments about this, please start a new thread, tagging it with Code Signing so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Resolving errSecInternalComponent errors during code signing In some circumstances the codesign command might fail with the error errSecInternalComponent. For example: % codesign -s "Apple Development" "MyTrue" MyTrue: errSecInternalComponent This typically affects folks who are signing code in a nonstandard environm...

iOS:检测使用VPN或Proxy

参考链接: https://www.jianshu.com/p/c3b950dbf86a https://gist.github.com/PramodJoshi/4faad4c91f7dcb4eb9b06be8390c01db http://noodlecode.net/2018/04/check-if-ios-app-is-connected-to-vpn 第一种方法 需要导入框架CFNetwork 然后,这个方法是mrc的:需要添加-fno-objc-arc的flag 代码如下: + ( BOOL )getProxyStatus { NSDictionary *proxySettings = NSMakeCollectable ([( NSDictionary *) CFNetworkCopySystemProxySettings () autorelease]); NSArray *proxies = NSMakeCollectable ([( NSArray *) CFNetworkCopyProxiesForURL (( CFURLRef )[ NSURL URLWithString: @"http://www.google.com" ], ( CFDictionaryRef )proxySettings) autorelease]); NSDictionary *settings = [proxies objectAtIndex: 0 ]; NSLog ( @"host=%@" , [settings objectForKey:( NSString *)kCFProxyHostNameKey]); NSLog ( @"port=%@" , [settings objectForKey:( NSString *)kCFProxyPortNumberKey]); NSLog ( @"type=%@" , [settings objectForKey:( NSString *)kCFProxyTypeKey]); if ([[settings object...

去广告DNS设置,国内ADGuard DNS方案,手机电脑iOS去广告,保护隐私

 原文链接 之前分享过使用mac系统搭建adguard home,这几个月用下来零零散散基本上也被弃用了。主要原因是因为需要保持电脑一直开机。但是我的电脑是笔记本,存在移动各个地域的情况,也就是说只能够屏蔽电脑自身,对于手机而言不太现实。今天偶然发现dnspod推出了高级版的公共解析。dnspod背靠腾讯云,肯定是合法合规的公共解析服务,这个高级版用起来不错。 国内自己搭建解析服务是违法行为,所以这也是为什么使用dnspod的原因。 后台截图 开始使用 首先我们先进入dnspod的公共解析页面,点击开始使用。 专业版公共解析 dnspod会提供几种预设,我们选择「开发者」即可 开发者 然后你就成功的申请到自己个人使用的dns了! 更新拦截规则 我们可以将常见的广告过滤规则加入到dns中。我们在顶部选项卡中选择「拦截规则」。 拦截规则设置 打开adguard adguard 绑定iOS设备 推荐使用描述文件的方式,删除配置时删除描述文件即可。 描述文件 绑定macOS 推荐使用描述文件的方式,删除配置时删除描述文件即可。 描述文件 mac需要在「系统偏好设置」的「网络」中查看是否正在运行。 代理 如果没有运行需要点击「···」来启动服务。 启动服务 绑定路由器 找到自己路由器的DHCP设置,修改dns,然后记得绑定自己的ip。 修改dns 绑定ip 费用 目前有300万次/月的免费额度,但没有超出之后的价格。300万次一个人比较难用完,可以放心使用。 我个人使用iOS设备两台、智能家居、电脑两台,日均请求数大致2万/日。 判断是否搭建成功 可以通过查看日志的方式,日志大概有半小时到一小时的延迟,请耐心等待。