I have a phoenix app which is using Pigeon this library which can send a notification to both android and ios using fcm or apns.
I’m trying to send a notification to ios device using apns and that’s how I have configured it
config :pigeon, :apns,
apns_default: %{
key: "AuthKey.p8",
key_identifier: "ABC1234567",
team_id: "DEF8901234",
mode: :dev
}
So when I’m trying to send message
n = Pigeon.APNS.Notification.new("your message", "device token goes here")
Getting this timeout error in response
%Pigeon.APNS.Notification{
collapse_id: nil,
device_token: "f5b76",
expiration: nil,
id: nil,
payload: %{"aps" => %{"alert" => "your message"}},
priority: nil,
push_type: "alert",
response: nil,
topic: nil
}
I’m trying to trace the error but not able to figure out
Pigeon.APNS.push(n)
[error] GenServer #PID<0.1321.0> terminating
** (MatchError) no match of right hand side value: {:error, {:asn1, {{:invalid_tag, 2}, [{:asn1rt_nif, :decode_ber_tlv, 1, [file: 'asn1rt_nif.erl', line: 85]}, {:"PKCS-FRAME", :decode, 2, [file: 'PKCS-FRAME.erl', line: 155]}, {:public_key, :der_decode, 2, [file: 'public_key.erl', line: 272]}, {:jose_public_key, :pem_entry_dec, 1, [file: 'src/jose_public_key.erl', line: 153]}, {:jose_public_key, :pem_entry_decode, 1, [file: 'src/jose_public_key.erl', line: 60]}, {:jose_jwk_pem, :from_binary, 1, [file: 'src/jose_jwk_pem.erl', line: 31]}, {:jose_jwk, :from_pem, 1, [file: 'src/jose_jwk.erl', line: 377]}, {JOSE.JWK, :from_pem, 1, [file: 'lib/jose/jwk.ex', line: 164]}, {Joken.Signer, :create, 3, [file: 'lib/joken/signer.ex', line: 81]}, {Pigeon.Configurable.Pigeon.APNS.JWTConfig, :generate_apns_jwt, 2, [file: 'lib/pigeon/apns/jwt_config.ex', line: 245]}, {Pigeon.Configurable.Pigeon.APNS.JWTConfig, :put_bearer_token, 2, [file: 'lib/pigeon/apns/jwt_config.ex', line: 234]}, {Pigeon.Connection, :send_push, 3, [file: 'lib/pigeon/connection.ex', line: 142]}, {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 2111]}, {Pigeon.Connection, :handle_events, 3, [file: 'lib/pigeon/connection.ex', line: 97]}, {GenStage, :consumer_dispatch, 6, [file: 'lib/gen_stage.ex', line: 2395]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 637]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 711]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}}
(public_key 1.7.2) public_key.erl:276: :public_key.der_decode/2
(jose 1.9.0) src/jose_public_key.erl:153: :jose_public_key.pem_entry_dec/1
(jose 1.9.0) src/jose_public_key.erl:60: :jose_public_key.pem_entry_decode/1
(jose 1.9.0) src/jose_jwk_pem.erl:31: :jose_jwk_pem.from_binary/1
(jose 1.9.0) src/jose_jwk.erl:377: :jose_jwk.from_pem/1
(jose 1.9.0) lib/jose/jwk.ex:164: JOSE.JWK.from_pem/1
(joken 2.2.0) lib/joken/signer.ex:81: Joken.Signer.create/3
(pigeon 1.5.1) lib/pigeon/apns/jwt_config.ex:245: Pigeon.Configurable.Pigeon.APNS.JWTConfig.generate_apns_jwt/2
(pigeon 1.5.1) lib/pigeon/apns/jwt_config.ex:234: Pigeon.Configurable.Pigeon.APNS.JWTConfig.put_bearer_token/2
(pigeon 1.5.1) lib/pigeon/connection.ex:142: Pigeon.Connection.send_push/3
(elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
(pigeon 1.5.1) lib/pigeon/connection.ex:97: Pigeon.Connection.handle_events/3
(gen_stage 1.0.0) lib/gen_stage.ex:2395: GenStage.consumer_dispatch/6
(stdlib 3.12.1) gen_server.erl:637: :gen_server.try_dispatch/4
(stdlib 3.12.1) gen_server.erl:711: :gen_server.handle_msg/6
(stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_consumer", {#PID<0.1121.0>, #Reference<0.1877575852.1559232513.170645>}, [{:push, %Pigeon.APNS.Notification{collapse_id: nil, device_token: "f5b76e7db4baf7104eadef9d5ea6f1bc6f9484542866e4b3ab0f0ae9adedecd7", expiration: nil, id: nil, payload: %{"aps" => %{"alert" => "your message"}}, priority: nil, push_type: "alert", response: nil, topic: nil}, [on_response: #Function<3.61995141/1 in Pigeon.APNS.sync_push/2>]}]}
%Pigeon.APNS.Notification{
collapse_id: nil,
device_token: "f5b76e7db4baf7104eadef9d5ea6f1bc6f9484542866e4b3ab0f0ae9adedecd7",
expiration: nil,
id: nil,
payload: %{"aps" => %{"alert" => "your message"}},
priority: nil,
push_type: "alert",
response: :timeout,
topic: nil
}