简体   繁体   中英

Using content available push notifications to update iOS app

I am building an app that has can be used by the same user across multiple devices. Whenever the user updates a preference on one device, I want the changes to propagate to all the devices with the app whether they are on the foreground or on the background. Can I achieve this using push notifications {aps: {content-available: 1}} payload? Is there a restriction on which category of apps can use this?

Thanks

No there isn't a restriction on app category, you just have to implement the proper background mode in your xcode project.

You can use content-available for that, it's meant for when new information is available to the app and you want to update it locally before the user opens the app so it's more readily available. This is a perfect use case of that functionality.

From Apple:

The aps dictionary can also contain the content-available property. The content-available property with a value of 1 lets the remote notification act as a “silent” notification. When a silent notification arrives, iOS wakes up your app in the background so that you can get new data from your server or do background information processing. Users aren't told about the new or changed information that results from a silent notification, but they can find out about it the next time they open your app.

EDIT: One thing to note, don't make the preferences update only available through the push notification because they aren't 100% reliable. Make the info available to update upon opening the app as well so that you can be sure they got it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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