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 can I get apns4erl integrated with ejabberd #45

Closed
monkeyfdude opened this issue Feb 27, 2015 · 8 comments
Closed

How can I get apns4erl integrated with ejabberd #45

monkeyfdude opened this issue Feb 27, 2015 · 8 comments

Comments

@monkeyfdude
Copy link

I am new to erlang and ejabberd. I have gone through docs and tutorials on erlang and ejabberd.

I am still not sure how to integrate apns4erl with ejabberd. I need to be able to do the following:

  • Add apns4erl module to with ejabberd_hooks for event offline_message_hook
  • That should start the apns4erl module.
  • From there, every a offline message is received, I need to be able to call send_message from apns4erl.
  • Also, I need have an persistent connection from apns4erl to Apple APN server.

Would you be able to give me starting pointers on to get apns4erl started with ejabberd??

Do I need to start apns4erl application from my custom module that I will hook with ejabberd. is that how it will work??

Thanks in advance!
Gaurav Jain

@manuel-rubio
Copy link
Contributor

Yes, you can do it as you define. Create the hook for offline with the highest priority (and the lowest number to be sure is running before mod_offline) and send the push notification.

You'll also need a mechanism to register the tokens and retrieve them, and in the start of the module you can configure the connection getting the configuration params from the configuration of the module.

Remember to add the dependency in the rebar.config or rebar.config.script (depends if you want to use mongooseim or ejabberd).

Pretty easy :-)

@monkeyfdude
Copy link
Author

Thank you for your response. Right now, I am trying to figure out how to write the hook.

When I was looking at the code for apns4erl, it requires sys.config. Would you know where would I plug that in Ejabberd framework.

Also, please shed some more light on rebar.config part. What is that??

Thanks again

Right now, I wish I was you so that I could find it easy to do....just a light note!!!!

@manuel-rubio
Copy link
Contributor

No, is not needed to use sys.config, you can use the connect with all the params and get the params from the module configuration using gen_mod:get_module_opt/4 function.

@elbrujohalcon
Copy link
Member

@monkeyfdude when you figure it out, feel free to add a wiki page describing the process if you feel like it :)

@monkeyfdude
Copy link
Author

I will add my findings to wiki.

https://github.com/inaka/apns4erl/wiki/Ejabberd-with-apns4erl

@monkeyfdude
Copy link
Author

I think I am able to connect using apns:connect. How can I check if its a persistent connection?

Would it show up in netstat -ln....is there a timeout of inactivity on these connections??

I did get this in server logs:

<0.380.0> Feedback server disconnected. Waiting 18000000 millis to connect again...

@monkeyfdude
Copy link
Author

I get this error in ejabberd logs

gen_server 'test-connection' terminated with reason: {'module could not be loaded',[{jiffy,encode,[{[{<<"aps">>,{[{<<"sound">>,<<"chime">>}

First I did not find jiffy in ejabberd. Then I tried copying jiffy.so from apns4erl to $EJABBERD_ROOT/./lib/ejabberd/priv/lib/jiffy.so

But it did not help me.

EDIT:

I was able to resolve via processone/ejabberd#102

make distclean

@monkeyfdude
Copy link
Author

I can successful send push notifications to my device using apns4erl...closing resolved.

I may have other reliability related questions that I will ask in separate tickets

Thank you all for your help and support....no words can express it!!!!

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

3 participants