How to configure GCM push notifications?
Hi I want to activate GCM notifications.
so I have creates a new project in the google console with te following API

And this is the configuration... but obviously doesn't work.

Where is my error?
And the second question... how to test it?
Can I send a message to a user not connected and hi receive a notification on his android phone?
tnx MaX
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
@maxlinux2000 Let me take a look at this process. We're using a package i'm not familiar with to do the push notifications. So I need to brush up.
@geekgonecrazy For what it's worth, if you are referring to raix:push we are using an outdated RC version. Might be an opportunity to update.
@gmsecrieru good point! Hopefully its more flexible.
@maxlinux2000 I also have problems configuring GCM push notifications. I found a way to check if the phone receives the notification on stackoverflow (provide there the API key and the device ID (you can find this id in the logs of the server when you login the first time on a new phone))
I can receive the notifications from this php script, but not from the rocketchat server.
I hope this helps.
... the ID of my phone? sorry but I don't understand. witch server and witch log in order to get this ID?
Another problem, the interface of the google console has changed a lot. Do you know any recent tutorial how to configure the push notification? I want to check if something is wrong in my configuration.
MaX
Sorry I didn't explained myself well.
I expect you have your Rocket.Chat running on your own server (e.g. on docker like for me) and you build your android application like explained in this article.
After you built the application you install it on your phone and log in to your server. During the login you check the stdout of your server. (with docker you can do it with docker logs -f "containername"). Then the server will write something like this:
[method] loadLocale: de
CLIENT register [ 'OK' ]
CLIENT token [ { gcm: 'A** ... **' } ]
[publish] settings
[publish] admin-settings
Where A****** is the device ID.
Afterwards you can follow the article on stackoverflow to check if your phone receives the notification you sent from phpfiddle.
Meanwhile I managed to make the push notifications work. For me it didn't work in the beginning because I didn't restart the server after I configured push notifications. (Could be nice to have a hint that a restart is required)
Many many tnx for your help.
Please post here some screenshot of your google console configuration, about the GCM.(obviously deleting private data)
Another question about these mysterious (for me) GCM in rocket.chat: If you send a private message to a user that is not connected, this user will be receive immediately a push message on his phone like whatsapp?
On 10/17/15, Tharnas [email protected] wrote:
Meanwhile I managed to make the push notifications work. For me it didn't work in the beginning because I didn't restart the server after I configured push notifications. (Could be nice to have a hint that a restart is required)
Reply to this email directly or view it on GitHub: https://github.com/RocketChat/Rocket.Chat/issues/1096#issuecomment-148939097
ciao, MaX
Your welcome :-)
I went to here to get my API Key and Sender ID:
Then I provided this two ids to Rocket.Chat server like here: (and afterwards restarted the server!!!)
When I built the application i put a config.push.json file in the root folder of Rocket.Chat with the following content: (didn't test if this step is realy needed)
{
"gcm": {
"apiKey": "A*****",
"projectNumber": 8******
},
"production": true,
"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
After I installed the application on my phone, logged in and sent a message it looks like this:

Ok, I can confirm that the json file is not necessary because the chat wont run due the error that he can not load the push configutarion 2 times.
Now my problem :)
Push: Send message "@maxlinux2000" via query { userId: 'QPE3RsvcJ6bsaakQP' } I20151018-04:36:16.618(-4)? Push: Sent message "@maxlinux2000" to 0 ios apps 0 android apps I20151018-04:36:16.623(-4)? Push, GUIDE: The "Push.appCollection" is empty - No clients have registred on the server yet...
A question more: You android app, is this build in cordova/phonegap?
https://github.com/RocketChat/Rocket.Chat/wiki/Build-the-Android-Cordova-Web-App-and-connect-to-your-own-Rocket.Chat-Server
regards MaX
On 10/17/15, Tharnas [email protected] wrote:
Your welcome :-)
I went to here to get my API Key and Sender ID:
Then I provided this two ids to Rocket.Chat server like here: (and afterwards restarted the server!!!)
When I built the application i put a config.push.json file in the root folder of Rocket.Chat with the following content: (didn't test if this step is realy needed)
{ "gcm": { "apiKey": "A*****", "projectNumber": 8****** }, "production": true, "badge": true, "sound": true, "alert": true, "vibrate": true }After I installed the application on my phone, logged in and sent a message it looks like this:
Reply to this email directly or view it on GitHub: https://github.com/RocketChat/Rocket.Chat/issues/1096#issuecomment-148946597
ciao, MaX
When I send a message it looks like this:
[methods] canAccessRoom -> userId: XC****** rid: XC******jg******
stream.permissions.read XC****** XC******jg******
[methods] canAccessRoom -> userId: XC****** rid: XC******jg******
Push: Send message "@testuser" via query { userId: 'jg******' }
send to token { gcm: 'A************************' }
sendGCM [ 'A*****************' ] { _id: '3a**********',
createdAt: Sun Oct 18 2015 08:51:09 GMT+0000 (UTC),
createdBy: '<SERVER>',
from: 'push',
title: '@testuser',
text: 'Test',
payload:
{ rid: 'XC******jg******',
sender: { _id: 'XC******', username: 'testuser' },
type: 'd',
name: null },
badge: 1,
sound: 'chime',
apn: { text: '@testuser:\nTest' },
query: { userId: 'jg******' } }
Create GCM Sender using "A*******"
A:Send message to: A**********
Push: Sent message "@testuser" to 0 ios apps 1 android apps
Push, GUIDE: The "Push.appCollection" - No APN clients have registred on the server yet...
ANDROID: Result of sender: {"multicast_id":78*******,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:144******"}]}
Your result looks like that the app does not register at the server.
As I have a docker environment so I use this way to build it: https://github.com/RocketChat/Rocket.Chat/wiki/How-to-Build-Rocket.Chat-for-Android
Is it possible for you to chat between webpage and app? When you send the message from the webpage to the phone do you have the app open? (it will just send a notification when the app is not open / in foreground)
OK I understand the problem... Rocket.chat.cordova don't support push messages, so no way to have a cordova custom app that can substitute whatsapp.
So, new strategy: 2 app! One native with my custom rocket.chat One in cordova with others stuffs.
But I never built a native app, so please tell me if these steps are corrects:
In order to build my own rocket.chat app for android
a) a local ubuntu 14.04 - 64bit on machine with 4GB ram b) android studio with 22 and 23 sdk + java7 then I will install the envoronment for docker:
apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main
" > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y upgrade
apt-get install -y linux-image-generic-lts-trusty
reboot
and follow at reboot:
apt-get install -y docker-engine
docker run hello-world
docker installed!
Now the rocket.chat environment:
apt-get install -y openjdk-7-jdk
apt-get install -y bison git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip
apt-get install -y g++-multilib
git clone https://github.com/rocketchat/Rocket.Chat
docker run -i -t -v /root/Rocket.Chat rocketchat/meteor12androidbuilder
cd Rocket.Chat
meteor add-platform android
meteor add crosswalk
meteor build --server http://chat.mydomain.org ./build
and... if all run correctly I will have an apk configured for my server... correct?
Following, now I will configure a rocket,chat server in a VPS under ubuntu 14.04 64bit (with dns name chat.mydomain.org)
(clean ubuntu 14.04 64bit installation on vps with public IP address and all as root) (I know that is not good, but in this first phase I can't considerate the security problems)
apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main
" > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y upgrade
apt-get install -y linux-image-generic-lts-trusty
reboot
apt-get install -y docker-engine
docker run hello-world
git clone https://github.com/rocketchat/Rocket.Chat
docker run -i -t -v /root/Rocket.Chat rocketchat/meteor12androidbuilder
cd Rocket.Chat
meteor add-platform android
meteor add crosswalk
meteor build --server http://chat.mydomain.org ./build
With this, I will have a rocketchat server runnig a port 80 on http://chat.mydomain.org
that's sound good? Do you see something wrong or omitted?
regards MaX
I'm not sure if I realy got you. Why would you build 2 apps? One is enough.
I build mine like the following: (after I installed docker and probably git on a new clean machine)
cd /root/
git clone https://github.com/rocketchat/Rocket.Chat
docker run -i -t -v /root/Rocket.Chat:/home/Rocket.Chat rocketchat/meteor12androidbuilder
-- create apk
cd /home/Rocket.Chat
meteor add-platform android
meteor build --server http://chat.mydomain.org ./build
-- sign apk
cd build/android
-- if you don't have a keystore yet
keytool -genkey -alias appName -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 release-unsigned.apk appName
$ANDROID_HOME/build-tools/23.0.1/zipalign 4 release-unsigned.apk appName_`date +"%Y-%m-%d_%H-%M"`.apk
exit
(You will find the apk in /root/Rocket.Chat/build/android/appName_date +"%Y-%m-%d_%H-%M".apk)
I'm not sure if you need the signing only if you want to publish it through play store or also to install it on the phone.
You don't need to install all of this stuff "openjdk-7-jdk bison git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip g++-multilib" on the host machine (if I get it right). The docker image "rocketchat/meteor12androidbuilder" contians all the dependencies it needs.
The build of the apk in docker is independent on how you publish your server.
By the way I'm not sure if you can build the latest version as there are currently some issues: https://github.com/RocketChat/Rocket.Chat/issues/1156
TNX for the help!
before build it, I need to re-install my system from 0
My pc is a 64bit, but I'm using the 32bit version of ubuntu.... So backup, backup and backup!!
I think I will need 2 day before to build the app. I hope that the bug will be solved. :)
So, I will answer to this very interesting topic, asap. Now reboot to new installation and reconfigure all my system :(
regards MaX
On 10/18/15, Tharnas [email protected] wrote:
By the way I'm not sure if you can build the latest version as there are currently some issues: https://github.com/RocketChat/Rocket.Chat/issues/1156
Reply to this email directly or view it on GitHub: https://github.com/RocketChat/Rocket.Chat/issues/1096#issuecomment-149036423
ciao, MaX
You are welcome. I'm pleased to help you out.
Hi all, I'm coming back after rebuild from zero, my develop laptop with ubuntu 64bit.
During these day I've tried to build the chat in docker, with success, but I have a big problem:
I need to integrate with a Iframe the chat in my cordova app. I have altrady do this work, but now is rising again the on topic problem:
HOW TO add the push notifications (in Cordova)?
I'm search a plugin and this seem good: https://github.com/phonegap/phonegap-plugin-push
but I need an esay way to check if my app is sending the ID of the phone to the server chat. Is there a log in the server where i can chek it? where? (the server is a ubuntu 14.04 64bit.)
last but not last, Some one have experiencop how to use phonegap-plugin-push in a real proj?
regards MaX
Welcome back :-)
with you can run the following command to see the output of the server:
docker logs -f "containername"
When the client registers at the server you will see something like this:
[method] loadLocale: de
CLIENT register [ 'OK' ]
CLIENT token [ { gcm: 'A** ... **' } ]
[publish] settings
[publish] admin-settings
I think the client registers always after you installed the app and start it or log in. Not sure.
during the last days i have do a lot of works, far of my favourite chat, but now I'm back :)
I have some problem to build rocketchat without docker (https://github.com/RocketChat/Rocket.Chat/wiki/Deploy-Rocket.Chat-without-docker) due a bug.
... with your last post i assume that I can see the logs using the doker... correct?
but with your command I receive that:
root@chat:~# docker logs -f "rocket.chat" Cannot connect to the Docker daemon. Is 'docker -d' running on this host? root@chat:~#
My environment run in VPS server ubuntu 64bit and rocketchat is lauched with:
screen cd Rocket.Chat/ git pull meteor update meteor (ctrl-a-d to exit from screen)
How I can do it?
Sorry this is my fault, use docker logs -f rocket.chat (without ")
For building there is also an image for docker. I will write you later more detailed when i have more time.