mrDoctorWho / ejabberd_mod_gcm

Google Cloud Messaging API for Ejabberd (PUSH Messages)
MIT License
28 stars 24 forks source link

ejabberd_mod_fcm: Firebase Cloud Messaging #13

Open mrDoctorWho opened 8 years ago

mrDoctorWho commented 8 years ago

https://firebase.google.com/docs/cloud-messaging/send-message

dan085 commented 8 years ago

@mrDoctorWho Hello, I hope this very well. In the module only change the url by -defines (NS_FCM, "https://fcm.googleapis.com/fcm"). and works perfectly in my server!!

ritheshg commented 7 years ago

Hello mrDoctorWho ,

I have integrated mod_gcm with ejabberd and FCM for Android. I just followed instructions and setup mod_gcm, everything seems to be fine. But when I receive offline message, it is received by mod_gcm but further not sent to FCM.

I could see debug message at server "mod_gcm: got offline message" but when I debugged found out that it is not entering into below case statement where message sent to FCM. Could you please let me know if I am missing anything related to configuration at server or while sending a stanza from client ?

Stanza from client side,

<iq to='my_xmpp_server' from='rahul' id='eMUAt-728' type='set'>
<register xmlns='https://mytestxmppappfcm.firebaseio.com'><key>client token id</key></register>
</iq>

Flow does not get into case statement at server.

        %% Checking subscription
        {Subscription, _Groups} = 
            ejabberd_hooks:run_fold(roster_get_jid_info, ToServer, {none, []}, [ToUser, ToServer, From]),
        case Subscription of

mrDoctorWho commented 7 years ago

Hi @ritheshg,

What is the type of your message?

ritheshg commented 7 years ago

It is 'Type.chat', I am using Smack library at Android client side and sending 'Message' to other end.

mrDoctorWho commented 7 years ago
<register xmlns='https://mytestxmppappfcm.firebaseio.com'>

What is that URL? Have you changed it in the code as well? Were there any other changes in the code?

What ejabberd version are you using?

Are there any other modules installed that might rely on offline messages?

ritheshg commented 7 years ago
  1. This is the firebase URL I got it in 'google-services.json' after creating a project in Firebase console. I have changed in code as below, -define(NS_GCM, "https://mytestxmppappfcm.firebaseio.com").

Snippet from 'google-services.json'

 "project_info": {
    "project_number": "417769686398",
    "firebase_url": "https://mytestxmppappfcm.firebaseio.com",
    "project_id": "mytestxmppappfcm",
    "storage_bucket": "mytestxmppappfcm.appspot.com"
  },
  1. I am using ejabberd version 16.04.61

  2. Using below but same state is observed even after disabling this module.

    mod_offline:
    access_max_user_messages: max_user_offline_messages
mrDoctorWho commented 7 years ago

Flow does not get into case statement at server.

I don't think the execution flow could just stop on this. Did it go through the case below?

case Type of 
    "normal" -> ok;
    _ ->
ritheshg commented 7 years ago

Yes, It got into "normal" -> ok; and executed below statement.

{Subscription, _Groups} =
                                ejabberd_hooks:run_fold(roster_get_jid_info, ToServer, {none, []}, [ToUser, ToServer, From])
mrDoctorWho commented 7 years ago

So, do your users have subscription both?

ritheshg commented 7 years ago

Yes, both the users have subscribed. And below debug messages are shown for both the users, mod_gcm: updating last_seen for user [username]

mrDoctorWho commented 7 years ago

@ritheshg Could you please check if the original module works fine for you?

nileshbacancy commented 6 years ago

Hello @mrDoctorWho , @ritheshg , @dverdugo85 any one know how to FCM pushnotification in ejabberd same like below GCM link: https://github.com/joanlopez/ejabberd-mod-gcm https://github.com/joanlopez/ejabberd-mod-gcm/blob/master/src/mod_gcm.erl

Please help me if there is any mod_fcm.erl file I have installed 16.09 ejabberd version.

mrDoctorWho commented 6 years ago

@nileshbacancy I don't know if there's any

mrDoctorWho commented 6 years ago

Firebase is to replace GCM by April 11, 2019. I probably should have a look into that.