iPhone 后台通知

发布于 2024-10-22 11:25:18 字数 506 浏览 1 评论 0原文

我正在制作一个 iPhone 应用程序。我可以使用 AsyncUdpSocket 接收 UDP 消息。我希望应用程序在后台运行,当收到消息时,会向用户显示 UIAlertView,他可以进入应用程序,或忽略警报。 当应用程序在后台运行时是否可以检测到消息。

我需要一些东西来在此方法中执行我的代码吗?

- (void)applicationDidEnterBackground:(UIApplication *)application {    
}

我看了很多带有计时器的教程,但我不需要计时器来唤醒我的应用程序。我还了解到,在播放音乐、跟踪位置或使用 VOIP 时,这是可能的。

我需要播放假歌曲才能让我的应用程序运行吗?或者做类似的事情?

这个应用程序是为了安全起见,例如,如果有人触摸或移动您的摩托车/电脑/其他任何东西,您的 iPhone 可以提醒您并防止盗窃。

我阅读了其他类似的帖子,但没有找到答案。

谢谢你们给我提示或任何帮助/示例。

I'm making an iPhone app. I can receive UDP messages using AsyncUdpSocket. I want the app running in background, and when receive a message, an UIAlertView is displaying to the user, and he can enter in the app, or ignore the alert.
Is it possible to detect a message when the app is running in background.

Do I need something to execute my code in this method?

- (void)applicationDidEnterBackground:(UIApplication *)application {    
}

I saw lot of tutorials, with timer, but I don't need timer to wake up my app. Also I read that's it's possible while playing music, tracking position or using VOIP.

Do I need to play a fake song to keep my app running? or to do something like that?

This app is for security, for example if someone is touching or moving your motorbike/computer/whatever else, your iPhone can alert you and prevents from stealing.

I read other threads similar but didn't find an answer.

Thank you guys for giving me tips, or any help /sample.

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

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

发布评论

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

评论(2

动次打次papapa 2024-10-29 11:25:18

如果你不属于这三类应用程序之一,你就无法在未越狱的手机上在后台运行,如果你将该功能用于其他目的,Apple 不太可能批准你的应用程序。无论如何,UDP 可能不是最好的解决方案 - 如果您的手机离开其他设备(无论它是什么)所在的网络,它根本不会收到通知,无论它是否在前台。使用推送通知 API 可能会更好。

You can't run in the background on a non-jailbroken phone without being in one of those three categories of app, and Apple’s really unlikely to approve your app if you use that facility for another purpose. UDP probably isn’t the best solution for this anyway—if your phone leaves the network that the other device (whatever it is) is on, it won’t receive the notification at all, whether or not it’s in the foreground. You’re probably a lot better off using the push notification API.

遮了一弯 2024-10-29 11:25:18

这似乎是使用 Apple 推送通知 (APN) 的完美案例。您的应用程序可以注册以接收通知,手机将通过徽章、消息或声音的任意组合来提醒用户。听起来您已经有一个正在发送 UDP 消息的服务器,因此合并 APN 应该是最少的。特别是如果您使用第三方发送推送通知,例如 Urban Airship。 (我不隶属于他们,但在一个大型商业项目中使用过它们。)

根据定义,本地事件不会通过接收消息来触发。

This seems like a perfect case to use Apple Push Notifications (APN). You app can register to receive the notifications and the phone will alert the user with any combination of badging, messages, or sounds. Sounds like you already have a server that is sending the UDP messages, so incorporating APN should be minimal. Especially if you use a third-party to send the push notification, such as Urban Airship. (I am not affiliated with them, but have used them on a large commercial project.)

By definition, local events are not triggered by receiving a message.

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