Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jolamar
Copy link
Contributor

@jolamar jolamar commented Feb 15, 2023

Proposed solution to issue #161

@edamov edamov merged commit 208f5e9 into edamov:master Feb 15, 2023
@edamov
Copy link
Owner

edamov commented Feb 15, 2023

@jolamar Thank you for PR! It was added in 0.15.3

@yetdog
Copy link

yetdog commented Feb 15, 2023

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?

@edamov
Copy link
Owner

edamov commented Feb 15, 2023

Hmm... Please check the example in the bottom of this comment - #161 (comment)
Is that what you want to achieve?

@yetdog
Copy link

yetdog commented Feb 15, 2023 via email

@jolamar
Copy link
Contributor Author

jolamar commented Feb 15, 2023

$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.

@jolamar jolamar deleted the feature/live-activities branch February 15, 2023 20:18
@jolamar
Copy link
Contributor Author

jolamar commented Feb 15, 2023

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;
        }
    }

Details here https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns

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

Successfully merging this pull request may close these issues.

3 participants