Comments (15)
That is weird.
The expected (and actual for me) behaviour is this:
Can u provide any more relevant information?
from apns4ex.
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.
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.
Yeah this makes sense. APNS receives incorrect packet in that case and closes the connection.
from apns4ex.
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.
ok, I think I'll do this
from apns4ex.
Thanks!
from apns4ex.
Done. Also I've added error callback trigger on payload size error. Changelog
from apns4ex.
Thanks, will test today.
from apns4ex.
Tested 0.0.6 - ๐
from apns4ex.
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.
@kroucis hi, can u share logs? Maybe even complete code? As of now circumstances when it fails for you are not obvious.
from apns4ex.
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.
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.
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)
- [error] [APNS] failed to connect gateway.sandbox.push.apple.com:2195, reason given: {:options, {:password, "..."}} HOT 7
- Drop Hexate dependency HOT 2
- The debug message about Reconnect is wrong HOT 5
- alert-message string for Localizable.strings HOT 1
- Support category field HOT 1
- Push not received HOT 4
- Resend notifications when error is received HOT 2
- Allow APNS token from feedback to be encoded with lowercase HOT 2
- Handle message expiry
- Document that invalid sized tokens should be removed HOT 1
- Add push_async function
- Publishing to Hex HOT 1
- Callback Module wrong documentation HOT 2
- APNS.Callback's message_id not match APNS.Message's id HOT 1
- Push stops working after a few hours on Google Compute Engine HOT 2
- Apns did not working after a few of hours. HOT 2
- Apns HTTP2 support HOT 3
- New version in hex HOT 10
- Can't connect to APNS with OTP 21.0
- Callback module should receive a `completed/1` call. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apns4ex.