找到存在然后发送推送通知

I am using Openfire for the xmpp server and so far its been great. The problem I am facing now is with push notifications. The app is written in Xcode which gets user data from a PHP Api. Openfire is the xmpp server. The issue is that when the app sends a message to openfire I would need to also query the Php api to see if the user is online and if they are not, send a push notification. This would have to happen for each message sent and as you might guess that will affect performance with all those requests happening.

I have everything working, I just cant get past this hump. If only openfire would fife off a request of my choice upon receiving a message.

Can anyone suggest a better idea? Basically need to know if the user is online (presence) before so that I know to fire off the push notification.

One thing also for sending push notification php script is right or openfire have some plugin.

Thanks.

I think using php script to check for offline user is an expensive affair.

I have used ejabberd server. For which you can create custom modules using "offline_message_hook" and using this module you can invoke php script to send push notification.

This hook is called when someone send message to an offline user. Following link might be helpful.

http://jasonrowe.com/2011/12/30/ejabberd-offline-messages/

If you are stuck somewhere, I can help.