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

APNS: Change the push_type easily #241

Open
lgastler opened this issue May 22, 2023 · 1 comment
Open

APNS: Change the push_type easily #241

lgastler opened this issue May 22, 2023 · 1 comment

Comments

@lgastler
Copy link

Is your feature request related to a problem? Please describe.
When updating iOS LiveActivities via Push (docs) the push_type needs to be liveactivity. As far as I found, changing the push_type is only possible by creating Pigeon.APNS.Notification from scratch.

Like this (valid example for liveactivities):

notf = %Pigeon.APNS.Notification{
  id: nil,
  device_token: token,
  topic: "<your bundleID>.push-type.liveactivity",
  expiration: nil,
  priority: nil,
  push_type: "liveactivity",
  payload: %{
    "aps" => %{
      "timestamp" => System.system_time(:second),
      "event" => "update",
      "content-state" => %{
        "value" => 7
      },
    }
  }
}

Describe the solution you'd like
Creating the struct from scratch is not really a problem, but it would be nice to change that f.e. using a utility function. This is not only helpful for liveactivities but different types of push below a list of valid push_types values for APNS (see docs)

  • alert
  • background
  • location
  • voip
  • complication
  • fileprovider
  • mdm
  • liveactivity
  • pushtotalk
@laugehoyer
Copy link

laugehoyer commented Jun 20, 2023

The struct function can handle this for you.

msg = %{
  "timestamp" => System.system_time(:second),
  "event" => "update",
  "content-state" => %{
  "value" => 7
}
notf = Pigeon.APNS.Notification.new(msg, device_token, topic) |> struct(push_type: "liveactivity")

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