OGeek|极客世界-中国程序员成长平台

标题: 当应用收到通知时,IOS 向 HTTP 服务器发送请求 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:05
标题: 当应用收到通知时,IOS 向 HTTP 服务器发送请求

我是 IOS 开发新手,我尝试使用推送通知

根据this文章:

When the user’s device receives the push notification, it shows an alert, plays a sound and/or updates the app’s icon. The user can launch the app from the alert. The app is given the contents of the push notification and can handle it as it sees fit.

Android 开发中,我有一个 Service 来处理应用程序中的所有 PUSH 消息,当应用程序收到 PUSH 消息时,我可以向他发送 HTTP 请求。

所以我有一个问题 - 我如何在 IOS 中做同样的事情? (当应用收到 PUSH 通知时发送 HTTP 请求)



Best Answer-推荐答案


如果您的应用程序位于前台,则可以从委托(delegate)方法进行 http 调用。但如果它处于后台模式,那么它是不可能的。

如果最终可行,您也可以做一件事。无论何时生成通知,它都会从服务器生成,因此您可以同时调用您的 require http 函数。

如果这不可能,那么您可以在服务器上设置某些设置,并基于该设置,当用户下次打开应用程序时,您可以调用 http 请求。

希望对你有所帮助。

关于当应用收到通知时,IOS 向 HTTP 服务器发送请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30868627/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4