Closed jolamar closed 1 year ago
This is AWESOME - only one question - given that content-state is a nested item ( like alert), how do you leverage $push->setContentState to assign the desired (and number of) key/values?
Hmm... Please check the example in the bottom of this comment - https://github.com/edamov/pushok/issues/161#issuecomment-1431778344 Is that what you want to achieve?
Exactly - I had been using the individual methods thus far, but this is great. Thanks again Artur (and PR legend!)
$payload = Payload::create()
->setTimestamp(Carbon::now()->timestamp)
->setEvent('update')
->setRelevanceScore(75.0)
->setStaleDate(Carbon::now()->addMinutes(60)->timestamp)
->setContentState(['ourScore' => 54, 'opponentScore' => 23]);
Content state can be anything you defined in your LiveActivityAttributes (Swift). So passing in an array should be enough. Here is how they define the key in the docs https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2943363
The updated or final content for a Live Activity. The content of this dictionary must match the data you describe with your custom ActivityAttributes implementation. For more information, see Updating and ending your Live Activity with remote push notifications.
in Token.php we also need to add the pushtype for live activities ApnsTopic. I'll get another PR out for this but in case you need it now.
public function generateApnsTopic(string $pushType)
{
switch ($pushType) {
case 'voip':
return $this->appBundleId . '.voip';
case 'liveactivity':
return $this->appBundleId . '.push-type.liveactivity';
case 'complication':
return $this->appBundleId . '.complication';
case 'fileprovider':
return $this->appBundleId . '.pushkit.fileprovider';
default:
return $this->appBundleId;
}
}
Proposed solution to issue #161