Skip to content

Instantly share code, notes, and snippets.

@ramhoj
Created April 11, 2016 08:33
Show Gist options
  • Save ramhoj/0eba365d86670f9f1933c8e6ce1e6603 to your computer and use it in GitHub Desktop.
Save ramhoj/0eba365d86670f9f1933c8e6ce1e6603 to your computer and use it in GitHub Desktop.
verify_push.exs
# Run with iex -S mix run script/verify
defmodule Pitch.VerifyPush do
@valid_tokens [
"7a61a279e0a35396d08ce13131fa6e2278a404f53683f17a16e1d6566223c712" # add more here
]
@number_of_bad_tokens 10
@pool :my_pool_name
def verify do
for good_token <- @valid_tokens do
push_bad()
push_parallel(good_token)
end
end
defp push_bad do
unless @number_of_bad_tokens == 0 do
for _i <- (0..@number_of_bad_tokens) do
push_parallel()
end
end
end
defp push_parallel do
push_parallel(Base.encode16(:crypto.strong_rand_bytes(32), case: :lower))
end
defp push_parallel(token) do
notification = %{
loc_key: "LOC_KEY",
loc_args: ["loc args"],
body: "body",
title: "title",
title_loc_key: "TITLE_LOC_KEY",
title_loc_args: ["loc args"]
}
message =
APNS.Message.new()
|> Map.put(:alert, notification)
|> Map.put(:category, "category")
|> Map.put(:extra, %{some_data: 123})
|> Map.put(:support_old_ios, false)
|> Map.put(:token, token)
APNS.push_parallel(@pool, message)
token
end
end
Pitch.VerifyPush.verify()
IO.puts "Close with ctrl+c"
:timer.sleep(:infinity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment