问题
I would like to use push notification message without badge, message or sound, only with application related JSON in order to update app's content in realtime. These notifications useless when app is not running so I won't send them when app enters background or user idle (sending unsubsrcibe to my server ) and subscribe again when app enters foreground or user activity. Does Apple permit this usage of push notification? I wouldn't like to use polling or custom socket based solution.
回答1:
I am not sure push notification is the way to go for you.
you should use pushes very carefully, people don't like to receive notifications if there is not a good reason for that. (some people are addicted to leave the notification center clear of notifications, it's kind of an ocd..).
Now, I'm not sure when exactly you want to send the notifications, but if it is for update purposes and you would turn it off when the app is not running, why not just update every once in a while after starting the app using a simple rest server. if you don't want to alert the user (no sound, message, nor badge) then what's the point in pushing..
回答2:
Im sure there are more reasons to not use APNS for realtime communication with your server, but here are two 'blocker'
- you will not be able to unsubscribe from your server if the user lost connection.
- push notifications are not reliable in terms of delivery time. You will only get notice by the push-server that your apn is queued, not that it is actualy delivered.
回答3:
Apple specifically instructs against using it to send data. Only to notify that new data is available. And notifications are explicitly not real time.
来源:https://stackoverflow.com/questions/14439993/can-i-use-ios-push-notifications-for-app-realtime-content-update