batikansosun / iOS-16-Live-Activities-Dynamic-Island

Displaying live data on the Lock Screen and in the Dynamic Island with Live Activities & ActivityKit & WidgetKit
77 stars 7 forks source link

get pushToken #1

Closed xiaoyintoken closed 2 years ago

xiaoyintoken commented 2 years ago

I get pushtoken is nil all the time, how do you get it

wangyangcc commented 2 years ago

@xiaoyintoken You can get pushtoken in func update(activity: Activity<GroceryDeliveryAppAttributes>) method

batikansosun commented 2 years ago

I get pushtoken is nil all the time, how do you get it

Hi xiaoyintoken,

Every activity has push token data to update its content via Remote Push Notification. You can access token data like the below code.

Eligibility Conditions

Push Notifications Capability Background Modes - Remote Notifications Push Notification Request Authorization Physical Device OR "To test remote push notifications for Live Activities in Simulator, use a Mac model with the Apple T2 Security Chip or a Mac with Apple silicon that runs macOS 13 or later."

var activities = Activity<GroceryDeliveryAppAttributes>.activities let pushTokenData = activities.first?.pushToken

batikansosun commented 2 years ago

I'm going to close the issue. If you get any errors reopen it.