new stand push and execute code

2019-09-03 19:51发布

问题:

Can I set my app as a newsstand app, close the app, then send a push notification that will trigger a background download operation?

What is the payload I need to add to my notification?

I've added content-available 1 and nothing in the app happens. It's not woken up.

I've successfully received other alert notifications when the app is asleep, so I know the pushes work..... they just won't wake up the app.

回答1:

The problem was / solution is:

I was using "content-available":"1" ..... when I should have been doing "content-available":1

...without the quotes around the 1.

So.... {"aps": {"content-available":1,"alert":"content test","badge":0,"sound":"default"}, "device_tokens": ["my-device-token-goes-here"]}

is treated as a background notification for newsstand, whereas if I quote the 1 it appears on the device as a normal push notification!

Hope this helps someone else.