Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何接收推送,更新实时活动? #1

Open
tiayako opened this issue Oct 25, 2022 · 6 comments
Open

如何接收推送,更新实时活动? #1

tiayako opened this issue Oct 25, 2022 · 6 comments

Comments

@tiayako
Copy link

tiayako commented Oct 25, 2022

如题,当前已获取到pushToken, 模拟推送到app,一直显示 TopicDisallowed,已设置 apns-topic = com.sa.SALiveActivities.push-type.liveactivity; apns-push-type = liveactivity; 不知道作者是如何更新的,希望能更新一版demo让大家共通进步,感谢!!

@jerryliurui
Copy link
Owner

已更新readme -> 关于Push更新

@tiayako
Copy link
Author

tiayako commented Oct 26, 2022

推送的时候,一直报 TopicDisallowed,不知道何原因

@tiayako
Copy link
Author

tiayako commented Oct 26, 2022

curl -v -d '{
"aps": {
"timestamp": 1666777826,
"event": "update",
"content-state": {
"driverName": "Tony Stark",
},
"alert": {
"title": "Avengers Race Update",
"body": "Tony Stark is now leading the race!"
}
}
}' -H "apns-topic:com.sa.salivea.push-type.liveactivity" -H "apns-push-type:liveactivity" -H "authorization: bearer eyJhbGciOiJFUzI1NiIsImtpZCI6IktXOUQ4RjgyVzYifQ.eyJpc3MiOiJON0MyUlNNTENYIiwiaWF0IjoxNjY2Nzc0MjI2LCJleHAiOjE2NjY3Nzc4MjZ9.QvCNkZ262esIqiHSAgzpxfJFramI4xm7GaBLPpaxi68Ik8Ct0NFjgQun4gkZaQ0ukQ0IH0FcPfmApDDDvXN_mQ" --http2 --cert /Users/mima123456/Downloads/ck.pem https://api.sandbox.push.apple.com/3/device/808c751733f239906678e7581274d23c1c4eb828f7fa86121a6cad69ec8f231ca30ab25ec02a1aa22a24eb6406f8e62dcea9e59f1c2decf8bf1f7b3786c25497c13a02f6f890691c2fd4222e54f22193

@jerryliurui
Copy link
Owner

你是用的tokenbase还是证书呀 感觉你的这个curl不应该有cert部分 去掉试试?
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns

@jerryliurui
Copy link
Owner

jerryliurui commented Oct 27, 2022

"To use remote push notifications to update your Live Activities, you need to use push tokens for authenticating with APNs as described in Establishing a Token-Based Connection to APNs." @tiayako

@jerryliurui
Copy link
Owner

curl --location --request POST 'https://api.sandbox.push.apple.com:443/3/device/**your live token here**'
--header 'authorization: bearer your base token here'
--header 'apns-push-type: liveactivity'
--header 'apns-id: eabeae54-14a8-11e5-b60b-1697f925ec3b'
--header 'apns-expiration: 0'
--header 'apns-priority: 10'
--header 'apns-topic: yourbundleID.push-type.liveactivity'
--header 'apns-collapse-id: demo_coll'
--data-raw '{
"aps": {
"timestamp": 1666754815,
"event": "update",
"content-state": {
"homeScore": 22,
"guestScore": 32,
"tips": "1234",
"score": "helloworld",
"time": 1665653260
},
"alert": {
"title": "Delivery Update",
"body": "Your pizza order will arrive soon.",
"sound": "example.aiff"
}
}
}'

@tiayako

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants