问题
I would like to know how to detect when user removes or adds today extension. If Apple does not have any method to do that, please suggest some ways for me to detect it.
Thank you very much for your time to answer my question.
回答1:
You cannot detect when the user adds or removes a today extension. You can detect when an extension is run for the first time by reading/writing a value to NSUserDefaults, but that's about it.
回答2:
If you don't need 100% accuracy, you could post [UIDevice currentDevice].identifierForVendor.UUIDString
to an external API every time the widget is loaded. This would give you a time record of every time the user looked at your widget (while connected to the Internet). If you stop receiving regular updates from one UUID:
- The user disabled your widget
- The user removed your app
- The user reset their vendor identifier
As I said, it won't be 100% accurate. That's about as close as you can get.
来源:https://stackoverflow.com/questions/26622393/ios8-today-extension-detect-removed-or-added-today-extension