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

Handle disconnections from apple internally #1

Closed
elbrujohalcon opened this issue Aug 14, 2012 · 0 comments
Closed

Handle disconnections from apple internally #1

elbrujohalcon opened this issue Aug 14, 2012 · 0 comments

Comments

@elbrujohalcon
Copy link
Member

After a couple of mails with @jamesgolick I understood that letting apns_connection processes die normally when they're disconnected from Apple is not the best idea. This is the final mail

Since my applications usually send packs of notifications (i.e. the same notification to a bunch of users instead of just one notification to some user)… I run this code right before trying to send each pack:

ensure_started() ->
  try apns:connect(?APPLE_CONNECTION,
                   fun handle_apns_error/2,
                   fun handle_delete_subscription/1) of
    {ok, _} ->
      ok;
    {error, {already_started, _}} ->
      ok;
    {error, Reason} ->
      ?THROW("Couldn't start APNS4ERL: ~p. Apple Push Notifications will not work until the admin fixes this~n", [Reason])
  catch
    _:Reason ->
      ?THROW("Couldn't start APNS4ERL: ~p. Apple Push Notifications will not work until the admin fixes this~n", [Reason])
  end.

After thinking about it for a while, I feel the right thing to do would be to keep apns_connection process running even when it was disconnected from Apple and then connect it again when it has a new notification to send… Most likely it would be a good idea to turn it into a gen_fsm… I'll probably implement that in the near future.

elbrujohalcon pushed a commit that referenced this issue Sep 5, 2013
allow adding extra staff into apn msg
elbrujohalcon pushed a commit that referenced this issue Jul 2, 2018
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