简体   繁体   English

即使在“删除”应用程序之后,有没有办法跟踪经过的时间?

[英]Is there a way to keep track of elapsed time even after app is “Deleted”?

I am developing an app (iPAD only) which shows user a pop up box after every 3 days (business requirement) from the "First" time he has installed the app. 我正在开发一个应用程序(仅适用于iPAD),该应用程序从“首次”安装该应用程序起每隔三天(业务要求)向用户显示一个弹出框。 I am using NSTimer to do it. 我正在使用NSTimer做到这一点。 The implementation breaks if the user deletes the app and reinstalls the app before three days period. 如果用户在三天前删除该应用程序并重新安装该应用程序,则实施会中断。 In this case the counter for 3 days restarts. 在这种情况下,三天的计数器将重新启动。 I know using Date might not be a good idea because user can change it from settings. 我知道使用日期可能不是一个好主意,因为用户可以通过设置更改日期。

Is there a way I can keep the NSTimer (or anything similar) to keep running even after app is deleted? 有没有办法可以使NSTimer(或类似的东西)在删除应用程序后仍保持运行?

NSTimer* msgTimer = [NSTimer scheduledTimerWithTimeInterval: 259200 target: self selector: @selector(showMsg:) userInfo: nil repeats: NO];

The only way I can think of doing this is every time the app is closed save a string representation of the last notification time in the keychain. 我能想到的唯一方法是每次关闭应用程序时,将最后一次通知时间的字符串表示形式保存在钥匙串中。 The keychain is not cleared when the app is removed. 删除应用程序后,钥匙串不会清除。 Although this is technically a misuse of the keychain it would probably work and I doubt you would have any store submission problems. 尽管从技术上讲这是对钥匙串的滥用,但它可能会起作用,我怀疑您会遇到任何商店提交问题。

Whenever the app is launched check if it is the first time it is launched since last installation (save this information in defaults). 每当启动该应用程序时,请检查它是否是自上次安装以来首次启动(将此信息保存为默认值)。 If it is the first time, check the keychain timestamp, compare against the current timestamp and go from there. 如果是第一次,请检查钥匙串时间戳,并与当前时间戳进行比较,然后从那里开始。

Say the user deletes the app and installs it the next day. 假设用户删除了该应用并在第二天安装了该应用。 Check keychain and you would see it was deleted 23 hours ago, then start your timer with 23 hours subtracted (so it will notify in 2 days 1 hour). 检查钥匙串,您会看到它在23小时前被删除,然后以减去23小时的时间启动计时器(因此它将在2天1小时内发出通知)。 Hope that all makes sense. 希望一切都有道理。

Otherwise if the app is generally connected to the internet you could use some sort of server. 否则,如果该应用程序通常已连接到互联网,则可以使用某种服务器。

No your app is sandboxed anything you do is gone when the app is deleted. 删除应用程序后,您的应用程序就不会沙箱化,您所做的任何事情都会消失。 You would need the help of some kind of web service to acheive your desired behavior 您将需要某种Web服务的帮助才能实现所需的行为

I don't believe so but I could be wrong (someone can be correct me). 我不这么认为,但我可能是错的(有人可以纠正我)。 Even if it is possible though this sounds like bad way to do something like this. 即使这听起来可能是做这样的事情的坏方法,也可能。

How about using Local Push Notifications to achieve something like this? 如何使用本地推送通知来实现这样的目标? Seems ideal for the situation. 似乎很适合这种情况。

Relevant Appl docs for setting up scheduled notifications 用于设置计划通知的相关Appl文档

You can also use iCloud's key-value data storage to store the initial install date. 您还可以使用iCloud的键值数据存储来存储初始安装日期。 If you store the date both locally and sync it from iCloud, then it will be difficult for the user to avoid getting the update unless they stay off the Internet. 如果您同时在本地存储日期并从iCloud同步日期,那么除非用户不上网,否则用户将很难避免获取更新。

This, of course, is dependent on them being logged into iCloud on the device and requires iOS 5 or greater. 当然,这取决于它们是否已在设备上登录到iCloud,并且需要iOS 5或更高版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使在电话被擦除后也要跟踪iOS设备 - Keep track of an iOS Device even after phone is wiped 即使应用程序被终止或在后台,是否有办法跟踪 GPS 本地化? Flutter 应用程序 - Is there a way to track GPS localisation even with the app killed or in background? Flutter app 有什么方法可以从后台跟踪当前正在运行的应用程序? - Any way to keep track of current running app from background? 即使在删除应用程序iPhone后也会收到推送通知 - Receiving push notification even after the app is deleted iPhone iOS 5-没有更多的UDID-即使删除了应用程序,如何保留一些关键数据来识别用户 - iOS 5 - No more UDID - How to keep some critical datas to identifiy the user even if app is deleted 以编程方式添加的UIButton即使在更改或删除图像后仍保留背景图像 - Programmatically added UIButtons keep the background image even after the image is changed or deleted 即使已删除该对象,也要使其保持活动状态 - Keep alive nsmangedobject even if it has been deleted 即使在关闭应用程序后,插座仍可以保持活动状态吗? - Is it possible to keep a socket alive even after closing the app? iOS CoreMotion API-是否可以跟踪一段时间内某人走路的次数? - iOS CoreMotion API — Is there a way to keep track of how many times someone goes walking over a period of time? 如何在不同时间段内跟踪数据(快速)-计数器/习惯跟踪应用程序 - How to keep track of data over various periods of time (Swift) - Counter/Habit Tracking App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM