简体   繁体   English

当应用程序收到通知时,IOS 向 HTTP 服务器发送请求

[英]IOS send request to HTTP server when app received notification

I'm new in IOS development, and i try to work with push notifications我是 IOS 开发的新手,我尝试使用推送通知

According to this article :根据这篇文章:

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.该应用程序会收到推送通知的内容,并可以按照它认为合适的方式进行处理。

In Android development i have a Service which handle all PUSH-messages in application and i can send HTTP request from him when app received PUSH-message.Android开发中,我有一个服务来处理应用程序中的所有 PUSH 消息,当应用程序收到 PUSH 消息时,我可以向他发送 HTTP 请求。

So i have a question - how i can do the same thing in IOS?所以我有一个问题 - 我如何在 IOS 中做同样的事情? (Send HTTP-request when app received PUSH-notification) (当应用收到推送通知时发送 HTTP 请求)

If you app is in Foreground then its possible to make http call from delegate method.如果您的应用程序在前台,则可以从委托方法进行 http 调用。 But if its in background mode then its not possible.但是如果它处于后台模式,那么它是不可能的。

Alternatively you can do one thing if its feasible at your end.或者,如果最终可行,您可以做一件事。 Whenever the notification will be generate it will be generated from the server so at the same time you can make call to your require http function.无论何时生成通知,它都会从服务器生成,因此您可以同时调用 require http 函数。

If that is not possible then you can set certain setting on server & based on that when user open the application next time, You can make call to http request.如果这是不可能的,那么您可以在服务器上设置某些设置,并在用户下次打开应用程序时基于此设置,您可以调用 http 请求。

Hope this helps you.希望这对你有帮助。

暂无
暂无

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

相关问题 如何确保iOS应用程序收到服务器发送的每个推送通知? - How to ensure that iOS app received EVERY push notification send by server? 当应用程序在后台时,来自 iOS 推送通知操作的 Http 请求 - Http request from iOS push notification action when app is in background 应用被杀死时是否收到 iOS 静默通知 - Is a iOS silent notification received when the app is killed iOS推送通知,收到消息后自动响应服务器 - iOS Push Notification, automatically response to server when received message 应用在前台运行时收到 iOS 推送通知 - iOS push notification received when app is running in foreground 在 iOS 上收到通知时确定应用程序是否在前台运行 - Determine if an app is running in the foreground when a notification is received on iOS 应用程序处于前台时未收到推送通知 ios flutter - Push Notification not received when app is in foreground ios flutter 当应用程序在iOS 10中处于后台时,未收到推送通知 - Push notification not received when App is in Background in iOS 10 如何知道应用程序何时收到通知以及用户何时在iOS中点击通知 - How to know when app received notification and when user clicked on notification in iOS 当应用程序从后台收到推送通知或在iOS中终止时,无法收听来自NSNotificationCenter的通知 - Unable to listen notification from NSNotificationCenter when App received push notification from background or terminated in iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM