创建一个闹钟,启动一个应用程序或在 iPhone 上的我的应用程序中启动代码

发布于 2024-10-05 19:21:08 字数 162 浏览 0 评论 0原文

我发现要在 iPhone 上创建闹钟应用程序,应该使用本地通知。

但是,这只会在给定时间开始播放声音。

我没有找到启动另一个应用程序或启动特定代码的方法,这应该在特定时间发生。

有办法做到这一点吗?如果可用,另请参阅示例应用程序。

非常感谢...

I found that to create an alarm app on iphone one should use Local Notifications.

However, this only starts to play a sound at a given time.

I did not find a way to start another app or to start specific code, that should happen a a specific time.

Is there a way to do this? If available, please also refer to a sample app.

Thanks very much...

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

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

发布评论

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

评论(2

萌梦深 2024-10-12 19:21:08

这很容易。只需使用 NSTimer 即可。检查文档。

[NSTimer scheduledTimerWithTimeInterval:15.00
    target:self selector:@selector(yourRoutine) userInfo:nil repeats:NO]

It's easy. Just use NSTimer. Check the doco.

[NSTimer scheduledTimerWithTimeInterval:15.00
    target:self selector:@selector(yourRoutine) userInfo:nil repeats:NO]
南街女流氓 2024-10-12 19:21:08

我不认为 N​​STimer 实际上完全回答了 OP 的问题?
我的假设是,他询问如何在他的应用程序当前未运行时启动应用程序或运行一些代码。仅当您的应用程序当前已在运行时,NSTimer 才会起作用。据我所知,您不能使用它来启动应用程序。

我也在努力寻找解决方案,以实现应用程序与后端 Web 服务的定期同步。在 Android 上,您可以使用 SyncAdapter 在后台启动您的应用程序,但在 iOS 中找不到类似的机制。

I don't think NSTimer actually fully answers the OPs question?
My assumption was that he was asking how to start an app or run a bit of code when his app is not currently running. An NSTimer will only work if your app is already currently running. As far as I'm aware you cannot use it to start an app.

I'm also struggling to find a solution to this to enable a periodic sync of an app with a backend web service. On Android you can use a SyncAdapter to start your app in the background, but cannot find a similar mechanism in iOS.

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