Giter VIP home page Giter VIP logo

Comments (15)

chvanikoff avatar chvanikoff commented on July 21, 2024

That is weird.
The expected (and actual for me) behaviour is this:
screenshot
Can u provide any more relevant information?

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

I just did

{:ok, conn}=APNS.start :dev
APNS.push conn, "0000000000000000000000000000000000000000000000", "test"

and received :ok, no other messages except

[debug] [APNS] Apple socket was closed
[debug] [APNS] connected to gateway.sandbox.push.apple.com:2195

Running on MacOS

elixir --version
Elixir 1.1.1
erl --version
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

My config.exs:

config :apns,
  certfile: [
    dev: "config/apn_certs/ck-dev.pem",
    prod: "config/apn_certs/ck-prod.pem"
  ]

config :apns,
  callback_module:  APNS.Callback,
  keyfile:          [dev: "config/apn_certs/key-dev.pem", prod: "config/apn_certs/key-prod.pem"],
  cert_password:    nil,
  timeout:          30000,
  feedback_timeout: 1200,
  reconnect_after:  1000

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

I think I know why. The size of the key matters! ;)
If I do APNS.push pid, "0000000000000000000000000000000000000000000000000000000000000000", "Hello world!" I get an error back. But if I do APNS.push pid, "00", "Hello world!" I get nothing.

Of course this is not a library's fault since apn4ex has no way of knowing if token is valid or has a valid length.

Thanks for you help and a great library!

from apns4ex.

chvanikoff avatar chvanikoff commented on July 21, 2024

Yeah this makes sense. APNS receives incorrect packet in that case and closes the connection.

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

I think it would be better to call error callback in this case as well. As a developer working with a library I want to have one callback to handle a case where the token was wrong. Token is the only thing that I don't control since it comes to me from a device. What do you think?

from apns4ex.

chvanikoff avatar chvanikoff commented on July 21, 2024

ok, I think I'll do this

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

Thanks!

from apns4ex.

chvanikoff avatar chvanikoff commented on July 21, 2024

Done. Also I've added error callback trigger on payload size error. Changelog

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

Thanks, will test today.

from apns4ex.

zepplock avatar zepplock commented on July 21, 2024

Tested 0.0.6 - ๐Ÿ‘

from apns4ex.

kroucis avatar kroucis commented on July 21, 2024

I still can't get the feedback callbacks to work at all (v 0.0.6). Below is my configuration:

config :apns,
  certfile:         "MyCertAndKey.pem",
  callback_module:  APNS.Callback,
  timeout:          30000,
  feedback_timeout: 1200,
  reconnect_after:  1000

from apns4ex.

chvanikoff avatar chvanikoff commented on July 21, 2024

@kroucis hi, can u share logs? Maybe even complete code? As of now circumstances when it fails for you are not obvious.

from apns4ex.

kroucis avatar kroucis commented on July 21, 2024

Here is the call to APNS

{:ok, pid} = APNS.start :dev
allTokens = Repo.all from pt in PushToken, select: pt.token
for token <- allTokens do
  APNS.push pid, token, "Hello!"
end
# I would call APNS.stop(id) here, but that kills the process before it can actually send anything to Apple.

Is it possible that calling APNS.start/1 and then sending notifications is somehow not giving the service enough time to start up the feedback connection?
Here are the logs for that code:

[debug] [APNS] connected to gateway.sandbox.push.apple.com:2195
[debug] [APNS] connected to feedback.sandbox.push.apple.com:2196
[debug] [APNS] Feedback socket was closed. Reconnect in 1200000s.

As a note: notifications appear to be working correctly.

from apns4ex.

chvanikoff avatar chvanikoff commented on July 21, 2024

Is it possible that calling APNS.start/1 and then sending notifications is somehow not giving the service enough time to start up the feedback connection? no it shouldn't be the case
But I want to ensure you are clear on feedback purpose:
The Apple Push Notification service includes a feedback service to give you information about failed remote notifications. When a remote notification cannot be delivered because the intended app does not exist on the device, the feedback service adds that deviceโ€™s token to its list. Remote notifications that expire before being delivered are not considered a failed delivery and donโ€™t impact the feedback service. By using this information to stop sending remote notifications that will fail to be delivered, you reduce unnecessary message overhead and improve overall system performance.

Are you sure feedback should be received? Can you also test with any wrong token and confirm error callback is properly triggered?

from apns4ex.

kroucis avatar kroucis commented on July 21, 2024

Ah! Fair enough. I was mistaken on the intent of the feedback system. When attempting with an invalid token, I get the following in red:

[error] [APNS] Error "Invalid token size" for message <<142, 231, 22, 86>>

This seems to be in line with what you are saying. Sorry for the false alarm.

from apns4ex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.