objective-c - 如何检测到 watchOS 应用程序已终止?
问题描述
我正在编写将由 watchOS 应用程序使用的 SDK。我需要像图像一样捕捉应用程序关闭的那一刻。甚至当应用程序从非运行状态变为活动状态时。现在我只能捕捉从非活动到活动的过渡。
我已经尝试过这个:
_applicationWillEnterForegroundObserver = [notificationCenter addObserverForName:@"UIApplicationWillEnterForegroundNotification" object:NULL queue:NULL usingBlock:^(NSNotification * _Nonnull note) {
[self willEnterForeground];
}];
_applicationDidBecomeActiveObserver = [notificationCenter addObserverForName: @"UIApplicationDidBecomeActiveNotification" object:NULL queue:NULL usingBlock:^(NSNotification * _Nonnull note) {
[self didBecomeActive];
}];
[notificationCenter addObserverForName:@"UIApplicationWillTerminateNotification" object:NULL queue:NULL usingBlock:^(NSNotification * _Nonnull note) {
[self willTerminate];
}];
_applicationWillResignActiveObserver = [notificationCenter addObserverForName:@"UIApplicationWillResignActiveNotification" object:NULL queue:NULL usingBlock:^(NSNotification * _Nonnull note) {
[self willResignActive];
}];
WillTerminate 通知根本不起作用。:( 我怎样才能做到这一点?
解决方案
推荐阅读
- c# - Mapster - 动态属性选择或忽略
- android - 如何处理 Android 的 App 用户会话
- java - 如何在 MicroProfile Rest Client 使用的 Json Serializer 上设置特定格式的表示?
- wagtail - 无法在 wagtail 中实现私有图像和文档的工作设置
- google-sheets - 如何在一个 Google 表格字段中提取数据并让它填充另一个 Google 表格字段?
- jmeter - JMeter“参数”变量不可转换为整数
- python - 如何将收到的消息发送回所有其他连接的客户端(线程)?
- python - 如何设置 Tkinter 框架的背景以随框架扩展?
- python - 从检查按钮检索属性 - Tkinter、检查按钮、python
- if-statement - 无法在 IF 语句中声明全局变量(Pine 脚本)