B4J Question B4J and Google Cloud Message

Discussion in 'B4J Questions' started by Mark Thorndyke, Mar 25, 2015.

  1. Mark Thorndyke

    Mark Thorndyke Member Licensed User


    Working on a nice little personal gaming project using both B4A and B4J. Successfully talking to various Androids using Google Cloud Messaging via a command line and/or via JShell using the b4a_gcm.jar (ref: http://www.b4x.com/android/forum/threads/android-push-notification-gcm-framework-and-tutorial.19226/)

    I've a monitoring B4J running locally with a live GUI and acting accordingly on what various devices send data back to an online MySQL database via Php.

    Wondering if there is a more efficient way to embed using the b4a_gcm.jar instead of using the following when requried (as suggested in http://www.b4x.com/android/forum/threads/jshell-library.34661/#content)

    shl.Initialize("shl", "java", Array As String("-cp", "b4a_gcm.jar", "anywheresoftware.b4a.c2dm.C2DM", "send", "registered-device", "data"))
    shl.WorkingDirectory = "current directory for b4a_gcm.jar"
    Any suggestions/voices of experience/options/caveats appreciated. I will pour more water about this 'little' project as it grows but so far, looking too good.

    Note: B4i once this stage running fluently
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is not a bad solution. However as you are using B4J you can use B4X push server instead of the php script: B4X Push Server
    Especially if you intend to add support for iOS in the future.
  3. Mark Thorndyke

    Mark Thorndyke Member Licensed User

    Thanks Erel, will take a look at this very soon.
    Debating whether to pursue that side quickly this weekend in readiness if a quick diversion or continue on the path of getting the app done for Android first. I suppose the question I'm asking, would it be fairly quick to adapt/put in place or does it need a little more work compared to the method in place on the the B4J to GCM side? The iOS side I'd want to move onto promptly once the droid side is in a good testing area with friends, as others eager with iOS devices to play too. (It's a unique card game we've adapted over the years being moved into the virtual arena - had working in Flash a few years back but dropped due to mobile market)
  4. Erel

    Erel Administrator Staff Member Licensed User

    Running B4X push server is very simple. You can run it in 10 minutes (don't forget the comment out the two ios related lines in the code).
  5. Mark Thorndyke

    Mark Thorndyke Member Licensed User

    Cheers, will take a stroll through that during the Easter weekend and adapt with what I've currently got in place. Current method is working well and pretty satisfied with the workings, a bit to straight forward after bolting together - hats off to the code.

    I doubt this is possible but is there any way for a device to push anything back to a B4J server other than B4A/i updating a MySql database via PHP which is picked up by the a B4J process?
  6. Erel

    Erel Administrator Staff Member Licensed User

    B4J servers are regular http servers. It is very simple to send data from the device to the server.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice