简体   繁体   English

iOS推送通知,收到消息后自动响应服务器

[英]iOS Push Notification, automatically response to server when received message

My request is to send push notification from Server to iPhone. 我的请求是将推送通知从服务器发送到iPhone。 Everything is working well. 一切都很好。 Unless I need my iPhone side to be able to feedback to server side when receive notification immediately. 除非我需要我的iPhone端能够在立即收到通知时反馈到服务器端。 If my app is foreground, I can send HTTP request via didReceiveRemoteNotification method. 如果我的应用程序是前台,则可以通过didReceiveRemoteNotification方法发送HTTP请求。 But if my app is in background (click home button to exit), didReceiveRemoteNotification is not called at all! 但是,如果我的应用程序处于后台(单击主页按钮退出),则根本不会调用didReceiveRemoteNotification Why??? 为什么??? I'm pulling my hair! 我正在拔头发!

Technically i believe it's realizable. 从技术上讲,我认为这是可以实现的。 I check the "Whats App", phoneA sends message to phoneB: if phoneB is offline, phoneA only gets a single tick. 我检查“ Whats App”,phoneA将消息发送到phoneB:如果phoneB脱机,则phoneA仅获得一个滴答。 Later if phoneB get on line, phoneA will get a double ticks. 稍后,如果phoneB上线,phoneA将获得两次滴答声。 And if phoneB is in background, phoneA also can get a double tick. 如果phoneB在后台,则phoneA也可能会出现两次滴答声。 Which means although phoneB is in background, but it did something. 这意味着虽然phoneB在后台,但是它做了一些事情。

I'm wondering how Whats App can do when the app is in background. 我想知道当应用程序在后台运行时,Whats App怎么做。

Thanks a lot! 非常感谢! Regards, 问候,

Benroo 本鲁

Please see the screen shot and figure it out you did the same in ur app to get call the didReceiveRemoteNotification while your app in background 请查看屏幕截图,并确定您在应用中执行了相同操作,以在后台运行应用时调用didReceiveRemoteNotification 在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM