Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat: watchOS/tvOS/visionOS/SwiftUI support #300

Merged
merged 36 commits into from
Mar 26, 2024
Merged

Conversation

YoloMao
Copy link
Collaborator

@YoloMao YoloMao commented Feb 2, 2024

PR 内容

  • feat: watchOS support (Tracker)
  • feat: tvOS support (Autotracker)
  • feat: visionOS support (Tracker, spm)
  • feat: visionOS support (Tracker, cocoapods)
  • fix: adapt deep link to SwiftUI

遗留问题

测试重点

  • 所有平台支持以及集成方式,参考新增的 Demo 以及集成文档
  • Visit 事件逻辑是否正常,包括前后台切换是否会刷新 session 等等
  • 匿名 id 存储是否正常(删除应用再次重装应用,匿名 id 是否是同一个)
  • 事件是否能够正常入库、出库(关闭应用再次打开是否会将上次未发送的事件继续发送)
  • 当前网络状态是否正常获取(networkState = 4G or WiFi,以及断网时,是否会停止发送事件)
  • Pure SwiftUI App 是否能够集成 SDK,且对应平台支持的功能,如 MobileDebugger、DeepLink,是否正常
  • SDK 将忽略 watchOS 的网络可达性判断,始终发送请求,对于 watchOS 的网络测试说明,见下方 comment

@YoloMao YoloMao force-pushed the feat/watchos_v2 branch 2 times, most recently from cd937a4 to 7f9c3fc Compare February 6, 2024 07:25
@growingio growingio deleted a comment from codecov bot Feb 6, 2024
@growingio growingio deleted a comment from sonarqubecloud bot Feb 6, 2024
@growingio growingio deleted a comment from sonarqubecloud bot Feb 6, 2024
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: Patch coverage is 80.28169% with 42 lines in your changes are missing coverage. Please review.

Project coverage is 82.79%. Comparing base (59e5cdd) to head (dec8daa).

Files Patch % Lines
...ingTrackerCore/Network/GrowingNetworkPathMonitor.m 70.96% 18 Missing ⚠️
...ackerCore/DeepLink/GrowingAppDelegateAutotracker.m 14.28% 6 Missing ⚠️
...ackerCore/Network/GrowingNetworkInterfaceManager.m 84.61% 6 Missing ⚠️
Services/Screenshot/GrowingScreenshotProvider.m 86.20% 4 Missing ⚠️
Modules/Advertising/GrowingAdvertising.m 50.00% 3 Missing ⚠️
...kerCore/DeepLink/GrowingSceneDelegateAutotracker.m 33.33% 2 Missing ⚠️
GrowingTrackerCore/Event/GrowingEventManager.m 80.00% 2 Missing ⚠️
...owingTrackerCore/DeepLink/GrowingDeepLinkHandler.m 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #300      +/-   ##
==========================================
+ Coverage   82.28%   82.79%   +0.50%     
==========================================
  Files         140      140              
  Lines       10016    10099      +83     
==========================================
+ Hits         8242     8361     +119     
+ Misses       1774     1738      -36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@YoloMao YoloMao changed the title WIP feat: watchOS/tvOS/visionOS support WIP feat: watchOS/tvOS/visionOS/SwiftUI support Feb 20, 2024
@YoloMao
Copy link
Collaborator Author

YoloMao commented Feb 20, 2024

备注

SwiftUI 建议通过 UIApplicationDelegateAdaptor 进而使用 AppDelegate 管理生命周期,并在 application:didFinishLaunchingWithOptions: 中初始化 SDK,而不是在 App.init()(其将导致 SDK 初始化时通过 UIApplication sharedApplication 获取实例为 nil

Copy link

@YoloMao
Copy link
Collaborator Author

YoloMao commented Mar 26, 2024

网络测试分为:事件的网络请求成功与否,与网络可达性判断 2 个部分

  • watchOS 测试网络请求时,需使用真机,Simulator 上始终允许底层网络;

When writing watchOS networking code, test it on a real device; the simulator always allows low-level networking.

  • 需同时测试开启和关闭匹配的 iPhone 的网络连接 2 种场景,这是由于 watchOS 可通过匹配的 iPhone 进行网络连接;

Also, test your networking code in a wide variety of network environments. Specifically, test it when the paired iPhone is available and when the paired iPhone is not available. The best way to test the latter is to turn off both Wi-Fi and Bluetooth in the Settings app on the iPhone. Do not use Control Center for this. For an explanation of the difference between these two mechanisms, see Use Bluetooth and Wi-Fi in Control Center.

  • NWPathMonitor 始终返回 unsatisfied 状态;因此在 watchOS 上,SDK 所获取到的 networkState 始终是 UNKNOWN

watchOS blocks low-level networking outside of these specific circumstances. For example, if a normal app attempts to start an NWConnection, that connection will stay in the .waiting(_:) state with an error of ENETDOWN. Similarly, an NWPathMonitor will remain in the .unsatisfied state.

  • 因为 watchOS 可通过蓝牙/WiFi 将请求代理到 iPhone 上,因此真机上获取到的网络可达性没有意义;

On watchOS specifically, network requests often get proxied by your iPhone, so the watch’s ability to connect to a specific host is irrelevant.

参考:
https://developer.apple.com/documentation/technotes/tn3135-low-level-networking-on-watchos
https://support.apple.com/en-us/HT204562
https://forums.developer.apple.com/forums/thread/729568

@YoloMao YoloMao merged commit 0ef1b26 into master Mar 26, 2024
15 of 16 checks passed
@YoloMao YoloMao deleted the feat/watchos_v2 branch March 26, 2024 06:53
@YoloMao
Copy link
Collaborator Author

YoloMao commented Mar 28, 2024

SDK 所依赖的 google protobuf 对 visionOS via Cocoapods 的支持时间尚不明确 (估计是 3.27.0?),因此 SDK 先通过 SwiftPM 集成方式支持 visionOS

@YoloMao
Copy link
Collaborator Author

YoloMao commented Jul 12, 2024

Cocoapods 集成支持 visionOS 的版本已发布:https://github.com/growingio/growingio-sdk-ios-autotracker/releases/tag/4.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants