I'm currently using GCM for one of my apps but I send messages from my pc to each android app. What I need to do with my latest app is actually send messages via GCM from one android device to another, so this needs to be done in code in B4A from within the app itself.
You have the DB with all known IDs. It´s up to YOU to give your app the possibility to write to user with ID x with your DB-Data. To send it you can use a script on your webserver (php) which gets the info to send this message to user with id X from your app.