如何处理 Flutter/Dart 中的应用程序卸载?
How to handle app uninstallation in Flutter/Dart?
谁能告诉我是否可以在 Flutter 或更一般的移动开发中处理用户卸载应用程序时的情况,以便我们执行某些操作?我知道我们可以很容易地检测到应用程序何时切换到后台,但我不知道是否真的可以检测到卸载。
您可以在应用程序处于后台时进行操作。位置跟踪,向任何服务发送请求。您可以做您在一般 android 和 ios 应用程序中可以做的事情。但有一些缺失的部分。您可能需要使用包。部分付费。
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
if (state == AppLifecycleState.resumed) {
print("user came back to application");
} else if (state == AppLifecycleState.inactive) {
print("user within the application");
} else if (state == AppLifecycleState.paused) {
print("user threw into the background");
}
}
对于 iOS 你需要一个 APNs(Apple 推送通知服务),这种方式告诉你令牌无效,所以,这意味着设备已经没有应用程序
@Nuqo 说的对。没有快速的方法来处理应用程序的卸载。但是你可以设计一个通知系统,定期推送通知。 Firebase 将使用“NotRegistered”响应错误消息。这意味着用户已卸载您的应用程序。
从 official document 阅读更多内容。
谁能告诉我是否可以在 Flutter 或更一般的移动开发中处理用户卸载应用程序时的情况,以便我们执行某些操作?我知道我们可以很容易地检测到应用程序何时切换到后台,但我不知道是否真的可以检测到卸载。
您可以在应用程序处于后台时进行操作。位置跟踪,向任何服务发送请求。您可以做您在一般 android 和 ios 应用程序中可以做的事情。但有一些缺失的部分。您可能需要使用包。部分付费。
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
if (state == AppLifecycleState.resumed) {
print("user came back to application");
} else if (state == AppLifecycleState.inactive) {
print("user within the application");
} else if (state == AppLifecycleState.paused) {
print("user threw into the background");
}
}
对于 iOS 你需要一个 APNs(Apple 推送通知服务),这种方式告诉你令牌无效,所以,这意味着设备已经没有应用程序
@Nuqo 说的对。没有快速的方法来处理应用程序的卸载。但是你可以设计一个通知系统,定期推送通知。 Firebase 将使用“NotRegistered”响应错误消息。这意味着用户已卸载您的应用程序。
从 official document 阅读更多内容。