1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Java Question Firebase java Server jar

Discussion in 'Libraries developers questions' started by DonManfred, Oct 18, 2016.

  1. DonManfred

    DonManfred Expert Licensed User

    Based on https://firebase.google.com/docs/server/setup
    i found this code to implement.

    Code:
    // Initialize the app with a service account, granting admin privileges
    FirebaseOptions options = new FirebaseOptions.Builder()
        .setDatabaseUrl(
    "https://databaseName.firebaseio.com")
        .setServiceAccount(new FileInputStream(
    "path/to/serviceAccountCredentials.json"))
        .build();
    FirebaseApp.initializeApp(options);

    // 
    As an admin, the app has access to read and write all data, regardless of Security Rules
    DatabaseReference ref = FirebaseDatabase
        .getInstance()
        .getReference(
    "restricted_access/secret_document");
    ref.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        
    public void onDataChange(DataSnapshot dataSnapshot) {
            Object document = dataSnapshot.getValue();
            System.out.println(document);
        
    }
    });
    In my eclipse-project i referenced the jar

    [​IMG]

    And the code does not raise a problem inside Eclipse... The methods are not marked "as bad"
    [​IMG]

    [​IMG]

    BUT if i then want to compile the library with SLC i get the following error.

    [​IMG]

    The file firebase-server-sdk-3.0.1.jar does exists inside the libs folder of the project and also it is available in the B4J Additional libs folder.

    Why SLC (or java?) is not able to resolve the reference?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you send me the complete project?
     
  3. DonManfred

    DonManfred Expert Licensed User

    Sure!
    Will do later today when i am at home
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    There are duplicate classes in firebase-common.jar and firebase-server-sdk-3.0.1.jar. The builder in firebase-common.jar doesn't include the relevant methods. I think that you don't need firebase-common.jar at all.

    Note that if a class has instance variables then it shouldn't be an AbsObjectWrapper class. The wrapper will be lost and recreated in several scenarios.

    For example:
    Code:
    list1.Add(MyFirebaseDatabase)
    Dim fd As FirebaseDatabase = list1.Get(0'a new wrapper is created. Instance variables will be lost.
     
    DonManfred likes this.
  5. DonManfred

    DonManfred Expert Licensed User

    How can i prevent instance-variables to get lost then?

    It also happens in the B4A Firebase-Realtime databasewrapper when you get a reference from a reference. Event-Name for ex. is then null. Maybe the instancevariable ba too...

    it is there but it is not referenced in Build-Path in Eclipse....

    Or is the problem that the jars are available in the libs folder even if not referenced in Eclipse?
     
  6. DonManfred

    DonManfred Expert Licensed User

    yes, it is. Removing the not used jar fixed the issue....
    Ok, i now can start building a wrapper for B4J :D

    Thank you very much, @Erel
     
    johndb likes this.
  7. tigrot

    tigrot Well-Known Member Licensed User

    Hi Don,
    Did you succede in creating a wrapper for b4j ?
    I need to build a desktop client for firebase. I'm not sure if I use NET or B4j...
    Thank you
    Mauro
     
  8. sz4t4n

    sz4t4n Member Licensed User

    Hi, same question here.

    cheers
     
    tigrot likes this.
  9. tigrot

    tigrot Well-Known Member Licensed User

    Hi sz4t4b,
    search for DonManfred, You will find a list of libraries the great Don wrote. I have seen he has firebase Database ready but not for messaging.
    Ciao
    Mauro
     
  10. tigrot

    tigrot Well-Known Member Licensed User

  11. DonManfred

    DonManfred Expert Licensed User

    Firebase Messaging is already there. Search the forum
     
  12. tigrot

    tigrot Well-Known Member Licensed User

    Really??? For B4J ?
     
  13. DonManfred

    DonManfred Expert Licensed User

    i´m not sure the java server component is for Messaging too. I guess it is for the realtime database.
    It is this part what i am trying to do.

    You can easily create a server with B4J which sends out notifications. See the B4J example
     
    tigrot likes this.
  14. DonManfred

    DonManfred Expert Licensed User

    tigrot likes this.
  15. tigrot

    tigrot Well-Known Member Licensed User

    I did and it's quite simple to send message, but to get unsollicited messages from Google server you need to register and the only supported environments seems to be Android, IOS(the most disturbing OS) and Chrome(and compatible browsers). The protocol is not revealed and if you sniff packets you are not able to decode them because they are encrypted.
    Thank you Don. I don't know where you find time to give us such a valuable support. After giving school help to grandsons I have no time left to work! It's time to retire...
    Ciao e grazie
    Mauro
     
  16. tigrot

    tigrot Well-Known Member Licensed User

    I meant register callback to Google servers
     
  17. DonManfred

    DonManfred Expert Licensed User

    Î dont know if i understand correctly.

    What exactly are you trying to archieve?
     
  18. tigrot

    tigrot Well-Known Member Licensed User

    Bidirectional messaging between an android device and a PC(running a B4J pgm). I have used direct comunication to write from Android to Android and it worked for months with no issue at all.
    Forgive my English, last time I could practice was in october 2016!
     
Loading...
  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