Are push-to-start tokens app wide or per type?

Confusion

Based on the fact that the subscription is requested on a Activity type, I assumed that the push-to-start tokens would be different. But the push-to-start token for WidgetExtensionAttributes and WidgetExtensionAttributesOther were identical. This is misleading.

The code below prints identical tokens even though the name of the token and their underlying schema are different.

Code Sample

func getTokens() {
Task {
if let data = Activity<func getTokens() {
Task {
if let data = Activity<WidgetExtensionAttributes>.pushToStartToken {
print("exists:", data.hexadecimalString)
} else {
print("requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributes>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("new:", ptsTokenString)
}
}
}
Task {
if let data = Activity<WidgetExtensionAttributesOther>.pushToStartToken {
print("other exists:", data.hexadecimalString)
} else {
print("other requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributesOther>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("other new:", ptsTokenString)
}
}
}
}>.pushToStartToken {
print("exists:", data.hexadecimalString)
} else {
print("requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributes>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("new:", ptsTokenString)
}
}
}
Task {
if let data = Activity<WidgetExtensionAttributesOther>.pushToStartToken {
print("other exists:", data.hexadecimalString)
} else {
print("other requesting pushToStartToken")
for await ptsToken in Activity<WidgetExtensionAttributesOther>
.pushToStartTokenUpdates {
let ptsTokenString = ptsToken.hexadecimalString
print("other new:", ptsTokenString)
}
}
}
}

Activity Types

struct WidgetExtensionAttributesOther: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var age: Int
}
var addresses: [String]
}
struct WidgetExtensionAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var emoji: String
}
var name: String
}

Docs

After much investigation I noticed the wording of the docs kind of hint that the push-to-start token is per ActivityKit as it says:

An asynchronous sequence you use to observe changes to the token for starting a Live Activity with an ActivityKit push notification.

But docs and the API don't align well.

Questions

  • Is it correct that the push-to-start token is per app? If so then is there a reason that that API designers decided to still have to pass a specific type and not just make a request without passing a type?
    • Should I maybe file a radar?
  • Is it correct to say push-to-start is per app, while update tokens are per instance. i.e. if I have two soccer matches, then unless the push-to-start token was refreshed by the OS, then both would use the same push-to-start token, however each match would have a unique update token?
Answered by Technology Evangelist in 840503022

It is correct that push-to-start tokens are for your app and not a specific ActivityAttributes type. It is also correct that push update tokens are specific to a given Live Activity instance.

I can understand the confusion based on the fact that you must specify some attributes type when calling the method on Activity to get the push-to-start token, and that would be a great feedback report to file.

Accepted Answer

It is correct that push-to-start tokens are for your app and not a specific ActivityAttributes type. It is also correct that push update tokens are specific to a given Live Activity instance.

I can understand the confusion based on the fact that you must specify some attributes type when calling the method on Activity to get the push-to-start token, and that would be a great feedback report to file.

Are push-to-start tokens app wide or per type?
 
 
Q