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

How to get query and get data from FeebackService #48

Closed
monkeyfdude opened this issue Feb 28, 2015 · 6 comments
Closed

How to get query and get data from FeebackService #48

monkeyfdude opened this issue Feb 28, 2015 · 6 comments

Comments

@monkeyfdude
Copy link

In Apple APNS "The Feedback Service" doc section, this is mentioned:

Query the feedback service daily to get the list of device tokens. Use the timestamp to verify that the device tokens haven’t been reregistered since the feedback entry was generated. For each device that has not been reregistered, stop sending notifications.

  • Would you be able to tell how can I get the list of tokens using apns4erl from Apple Feedback Service?

There is a feedback connection. But how do I get data and process it? Is there an example?

Please provide pointers!

@manuel-rubio
Copy link
Contributor

when the connection is done to the feedback service, you'll receive those tokens, expired tokens, and you are responsible to remove them from your database (if you consider the token is not valid anymore).

The callback where you'll receive this is described here:

https://github.com/inaka/apns4erl#feedback-channel-and-getting-errors

handle_apns_delete_subscription({Timestamp, Token}) here you'll receive one by one all of those expired tokens.

@monkeyfdude
Copy link
Author

Clarifications needed please:

There are two ways we can get feedback

  1. When we send_message(INVALID_DEVICE_TOKEN), here we get a feedback that token is not valid
  2. As you mentioned above in your comment, when we open the connection to feedback service we start getting those tokens one by one
  • In both cases wiil it be the same callback or will it be different callbacks?
  • Do both cases share the same connection to the feedback service?
  • I notice that feedback connection gets disconnected. What will happen if feedback connection is disconnected and I send_message for invalid device token. Since feedback connection was down, how will the feedback callback be invoked?

Best Regards,

@manuel-rubio
Copy link
Contributor

Of course not. If you see the link above, you realize there're 2 callbacks. I was referring only to the second one, because you was asking about that, but you can implement both to handle the different incoming messages.

@monkeyfdude
Copy link
Author

I apologize but after looking at the link only, I got confused.

How many total callbacks will be implemented - Two or Three

  1. handle_apns_error/2 ------- used FOR send_message(...) for ERRORS

  2. handle_apns_delete_subscription/1 --------> used FOR send_message(....) for DELETE_SUBSCR

  3. handle_apns_delete_subscription/1 ------------> used BY feedback_connection for DELETE_SUBSCR

If two in total need to be implemented, then what will happen for send_message(DELETE_SUBSCR) call when Feedback Connection is NOT there

If three in total need to be implemented, my confusion is how do I provide reference to the third callback function.

Here we only give reference to two callback functions, one of which is for ERRORS

apns:connect(
%% your connection identifier:
my_connection_name,
%% called in case of a "hard" error:
fun ?MODULE:handle_apns_error/2,
%% called if the device uninstalled the application:
fun ?MODULE:handle_apns_delete_subscription/1
).

I think my confusion comes from that I assume for send_message(DELETE_SUBSCR) call, Feedback (different from error) will be sent right away by Apple APNS to apns4erl.

But I think the behavior would be that feedback of expired tokens token will only come when feedback connection is up next time. Is that the case?

@manuel-rubio
Copy link
Contributor

yes, is that.

@monkeyfdude
Copy link
Author

Thank you very much for helping me out!!!

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