How to use Firebase in iOS without Get-Taglist-Component?

Dear developers and community members,

does anyone has a clue, how to use the firebase for iOS with only the “get key” option?

I have managed to use firebase crossplatform (developer team is totally awesome), but I am struggling with the data structure:
Let’s say I have a parent node (“shared contacts”) in firebase, which has childkeys with names(key) and numbers(value) (imagine a storage of contacts).

Without a taglist, the iOS app will never know, when a new contact was added by another user or deleted. First I thought of firebase functions to resolve this issue, but it does not like to handle taglists like arrays or lists:

So my first attempt, to write a taglist with firebase-functions each time data is added to a special key, called “taglist” under the parent node has failed .

Currently, I do not see an alternative to add a get-taglist-component by an expert developer @thunkable, @arun, @albert, or anyone out of the community comes up with a really smart idea :nerd_face: .
Or has anyone experience in javascript DeltaSnapshot and the ForEach() method, which could maybe be used as a workaround?

Thx for hearing, keep thunking.
Cheers,
Use81

1 Like

… little workaround for now (took only half day :confused: )

‘use strict’;

const functions = require(‘firebase-functions’);
const admin = require(‘firebase-admin’);
admin.initializeApp(functions.config().firebase);

//do a snapshot of childnodes and store them as a list
exports.snaptoarray = functions.database.ref(‘testinput/{testkey}’).onWrite(event =>{

//const keyRef = event.params.testkey;
const parentRef = event.data.ref.parent;
const root = event.data.ref.root;

const testoutput = root.child(‘testoutput’).child(‘keylist’);

const listOfItems = [];

parentRef.once(‘value’).then(snap => {
snap.forEach(childSnap => {
const item = childSnap.key;
listOfItems.push(item);
console.log('item: ’ + item);
});
//return listOfItems;
}).then(() => {
return testoutput.set(listOfItems);
});
});

@thunkable
will it make sense to wait for a firebase get-taglist-component in thunkable ios?

Can try the following? If you set the key to empty, it will call the data change event block whenever there is a chance to the children.

19%20PM

Thank you for this smart idea, it will surely help many folks in the community :+1:

Unfortunely it does not solve my problems, because it only triggers, when changes are done and it gives too much information, when children have children and grandchildren.

What I need is like a simple “dir”-command in MS-DOS: just a simple overview of the keys of the children.

My best workaround for now is firebase functions with the Object.keys() command.

You see, I have very special demands when it comes to the firebase component. What else is needed badly (once a taglist is created) is a get-object component, which has a connectable property string -> to access all the child values for every item in the tag list.

Take your time for priorising, I know you have bunch of other creative stuff in the pipeline (perhaps also an enriched listview-component :wink: )

Cheers, User81

The workaround firebase function for anyone, who may need it:

exports.CreateTaglist1 = functions.database.ref(‘database_main/{cityid}’).onWrite(event=> {
const city = event.params.cityid;
const root = event.data.adminRef.root;
const itemToUpdate = root.child(‘database_taglist’).child(city);
const value = event.data.val();
const tagList = Object.keys(value);

return itemToUpdate.set(tagList).then(() => {
console.log(‘taglist created’);
});
});

How often do you need the tag list? or what is the use case?

Cheer,
Wei

I appreciate your support very much!

My app is like Google Maps for products (user-generated content). I need a tag list every time, a user wants to see which cities have insider tips already. Then every time a user wants to see, which categories are available in this city. And at last, when the user wants to see, which products are declared in a specific category.

/database_main/

  • —city1/
  • —city2/
    • —category1/
      • —product1: value
      • —product2: value

The only way, this can be done in thunkable iOS is to get the value of the most parent node and then slice the value (nested objects) with a complicated combination of text components in order to get the keys.

Screenshot 1 android,
Screenshot 2 android,
Screenshot 3 iOs.


I will try to make functions in thunkable, which can analyze the JSON after generating the JSON from object…
that will look like that screenshot, just with while-loop and some more stuff :thinking:

Actually, that should be really easy: I just need to analyse the String from index 1 to end of string and look for “{”, “:”, “,” and “}” :wink:

BTW: thx for the replace text component in iOS :hugs::star_struck:

1 Like

work done: L’interpréteur de JSON :ok_hand:

1 Like

Hi! How did you manage to solve this case? Can you please write an explanation of how you solved it because I have the same problem.

Thank you in advance.

the screenshot is the solution. please share your project, if you have trouble

I am not understanding the logic that’s why i asked. Can you explain how you are using this function in your program? I mean what is the input, what is the output and how can i use the output

can you please share an example project which shows your problem?
its really hard for me to figure out what you are asking for!

please take your time, make a screenshot, explain what you have done to solve your problem…

input: parent node from firebase
output: list of child node keys

do you understand these words?

1 Like

I am making an uber like app and in the driver app it will listen to serviceRequests childs and get the location of the user. The problem is how to get a userId that i don’t know yet and i think you had the same problem. Yes, I understand those words. Tell me if I wasn’t clear

thanks,
I understand.
from your screenshot I cannot understand where you want to get a taglist from realtime DB (firebase)

this thread is all about a taglist.

This thread was opened for everyone, who wants to get a taglist from firebase in thunkable X apps :slight_smile:

I understand. With taglist you mean in my case, a list of userId’s in serviceRequests. Right?

I think so.

Do you want to get a list from firebase of all userIDs under the node serviceRequests?