如何在iphone sdk中延迟应用程序退出时间?

发布于 2024-08-13 06:52:44 字数 294 浏览 7 评论 0原文

我想在我的应用程序终止时注册我的应用程序以获取推送通知,因此我认为如果我延迟应用程序退出时间,这是可能的。有人知道如何延迟应用程序退出时间吗?我认为这个方法

[self performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait];

可以完成我的工作,但我不知道如何使用这个方法,如果有人知道请告诉我。当我的应用程序退出时,我需要向服务器发送一些数据并注册推送通知。

I want to register my app for push notification when my application terminates so i think if i delay my app quitting time it could be possible.Does someone knows how to delay application quitting time? I think this method

[self performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait];

will do my job but i don't know how to use this method if someone knows please tell.I need to send some data to a server along with registering for Push Notification when my app quits.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-08-20 06:52:44

我无法想象你为什么要这样做。如果可能的话,用户点击主页按钮并且应用程序需要花费 x 时间才能关闭,这将是非常烦人的。这次“x”依赖于服务器连接,这让用户更加头疼。

苹果让主页按钮立即退出应用程序是有原因的。

如果您想按照建议注册推送通知,请在应用程序运行时进行操作。如果您担心如果用户过早退出,它们将无法正确设置...请不要这样做。
作为用户,我们都知道有时退出程序而不给它时间保存设置会产生后果。

I can't imagine why you would want to do this. If it were even possible it would be extremely annoying for a user to tap the home button and the app to take x amount of time to shut down. This time 'x' being dependent on the server connection creates even more user headache.

Apple have the home button exit apps immediately for a reason.

If you want to register the Push Notifications like you suggest, do it while the app is running. If your worrying that they won't be properly set if the user exits prematurely... don't.
As users, we all know there are sometimes consequences of exiting a program without giving it time to save your settings.

屋顶上的小猫咪 2024-08-20 06:52:44

对于推送通知,最好在应用程序首次启动时注册,然后在后台将推送令牌发送到您的服务器。但是,如果您有充分的理由需要在应用程序终止时进行注册,我相信您可以在使用 iOS 4 的情况下执行此操作。iOS 4 有一个名为“任务完成”的新功能,允许应用程序用户关闭它后保持运行几分钟,以便它可以完成正在进行的任何任务(例如保存数据)。

For push notification it is better to register when the app first starts and then send the push token to your server in the background. However, if you have a good reason why you need to do the registration just as the app terminates, I believe you can do this if you are using iOS 4. iOS 4 has a new feature called "task finishing" that allows an app to stay running for a few minutes after the user closes it so that it may finish up any tasks it was in the middle of (such as saving data).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文