iphone - ejabberd offline_message_hook not called -
i'm trying ejabberd server send offline push notifications using custom offline_message_hook module. problem hook never seems called. i've tried setting priority of hook 0, 49, , 50 still doesn't work.
this code module:
% name of module must match file name -module(mod_offline_push). %% every ejabberd module implements gen_mod behavior %% gen_mod behavior requires 2 functions: start/2 , stop/1 -behaviour(gen_mod). %% public methods module -export([start/2, stop/1, create_message/3]). %% included writing ejabberd log file -include("ejabberd.hrl"). %% ejabberd functions jid manipulation called jlib. -include("jlib.hrl"). start(_host, _opt) -> ?info_msg("mod_offline_push loading", []), inets:start(), ?info_msg("http client started", []), ejabberd_hooks:add(offline_message_hook, _host, ?module, create_message, 0). stop (_host) -> ?info_msg("stopping mod_offline_push", []), ejabberd_hooks:delete(offline_message_hook, _host, ?module, create_message, 0). create_message(_from, _to, packet) -> ?info_msg("creting offline message", []), type = xml:get_tag_attr_s("type", packet), froms = xml:get_tag_attr_s("from", packet), tos = xml:get_tag_attr_s("to", packet), if (type == "chat") -> post_offline_message(froms, tos) end. post_offline_message(from, to) -> ?info_msg("posting ~p ~p~n",[from, to]), httpc:request(post, {"http://host.com/push.php",[], "application/x-www-form-urlencoded", lists:concat(["from=", from,"&to=", to])}, [], []), ?info_msg("post request sent", []).
pass host or global hook, rather _host. hook needs registered specific host or global hook.
Comments
Post a Comment