logo
down
shadow

Retrieving Uid's from Firebase Database


Retrieving Uid's from Firebase Database

By : user2172635
Date : October 23 2020, 08:10 AM
With these it helps Base on the structure of your Database, the User ids will become the key when you loop through the received snapshot. To get the keys, simply call getKey() on your looped datasnapshot. You can do that by adding below code in between your loop and log it to your Logcat...
code :
String userIds = userSnapshot.getKey(); //Get keys
Log.d("USERID KEYS", userIds) //Log to logcat
...
     @Override
     public void onClick(View v) {

         Log.d("User ID",user.getUserId());
    }
...


Share : facebook icon twitter icon
Retrieving data from Firebase and using it in another Firebase database reference

Retrieving data from Firebase and using it in another Firebase database reference


By : Parmartha
Date : March 29 2020, 07:55 AM
around this issue A couple of things:
Firebase is Asynchronous and you have to account for that in your code. As it is in the post, the second Firebase function may execute before the first Firebase function has successfully returned data i.e. restaurantName may be nil when the second call happens.
code :
let ownersRef = rootRef.child("owners")
let restaurantRef = rootRef.child("restaurants")

func viewDidLoad() {
   fetchOwner("owner uid")
}

func fetchOwner(ownerUid: String) {

    var restaurantName: String?

    let uid = FIRAuth.auth()?.currentUser?.uid
    ownserRef.child(ownerUid).observeSingleEvent(of: .value, with: { snapshot in

        if let dict = snapshot.value as? [String: AnyObject] {
                restaurantId = dict["restaurant_id"] as? String
                fetchRestaurant(restaurantId)
            }
        }
    })
 }

func fetchRestaurant(restaurantId: String) {
    restaurantRef.child(restaurantId).observeSingleEvent(of: .value, with: { snapshot in

        if let dict = snapshot.value as? [String: AnyObject] {
            let restaurantName = dict["name"] as! String
            let menuDict = dict["menu"] as! [String:Any]
            self.dataSourceArray.append(menuDict)
            menuTableView.reloadData()
        }
    }
}
restaurants
    -Yii9sjs9s9k9ksd
       name: "Bobs Big Burger Barn"
       owner: -Y88jsjjdooijisad
       menu:
         -y8u8jh8jajsd
             name: "Belly Buster Burger"
             type: "burger"
             price: "$1M"
         -j8u89joskoko
             name: "Black and Blue Burger"
             type: "burger"
             price: "$9.95"
    let testRef = ref.child("test").childByAutoId()
    let key = testRef.key
    print(key)
Retrieving Data From Firebase Database Using Xamarin.Firebase.Database

Retrieving Data From Firebase Database Using Xamarin.Firebase.Database


By : Osama Saada
Date : March 29 2020, 07:55 AM
wish of those help Lets assume you have an POJO defined in Java (or Xamarin.Android-based C#) called User that contains a Name and Email property and the Name property is a unique key.
Calling the following adds two users, Bar and Foo to the usernames key:
code :
var userNamesRef = FirebaseDatabase.GetInstance(firebaseURL).GetReference(User.UserNameRoot);
var userSendToFirebase = new User("Bar", "bar@example.com");
var userRef = userNamesRef.Child(userSendToFirebase.Name);
userRef.SetValue(userSendToFirebase);
userSendToFirebase = new User("Foo", "foo@example.com");
userRef = userNamesRef.Child(userSendToFirebase.Name);
userRef.SetValue(userSendToFirebase);
var userNamesRef = FirebaseDatabase.GetInstance(firebaseURL).GetReference(User.UserNameRoot);
var userListener = new UserValueEventListener((sender, e) =>
{
  var userFromFirebase = (e as UserEventArgs).Value as User;
  Log.Debug(App.TAG, $"User Found!: {userFromFirebase.Name} : {userFromFirebase.Email}");
});
userNamesRef.OrderByChild("name").EqualTo("Bar").AddListenerForSingleValueEvent(userListener);
public class UserValueEventListener : Java.Lang.Object, IValueEventListener
{
    EventHandler OnChange;

    public UserValueEventListener(EventHandler OnChange) => this.OnChange = OnChange;

    public void OnCancelled(DatabaseError error)
    {
        Log.Warn(App.TAG, "Failed to read value:", error.ToException());
    }

    public void OnDataChange(DataSnapshot snapshot)
    {
        if (OnChange != null && snapshot.Value != null && snapshot.Key == User.UserNameRoot)
        {
            foreach (DataSnapshot item in snapshot.Children.ToEnumerable())
            {
                var user = item.GetValue(Java.Lang.Class.FromType(typeof(User))) as User;
                OnChange.Invoke(this, new UserEventArgs(user));
            }
        }
    }
}
How to read UIDs from firebase database

How to read UIDs from firebase database


By : Manoj
Date : March 29 2020, 07:55 AM
Does that help Your problem is the scope in which you are assigning this.user. You create a new scope, if you use function(), try using lambdas/arrow functions instead:
EDIT:
code :
//members.ts

export class MembersPage {
  user: [string] = [];

  constructor() {
    firebase.database().ref('Accounts').once('value', (mySnap) => {
        mySnap.forEach((uiDSnapshot) => {
            this.user.push(uiDSnapshot.key);
            console.log(this.user);
        }); 
    });
}
How to grant read-read/write access to specific UIDs from Firebase Auth and Database

How to grant read-read/write access to specific UIDs from Firebase Auth and Database


By : user2527736
Date : March 29 2020, 07:55 AM
wish help you to fix your issue One solution is to have some specific database nodes listing your users, as follows:
code :
{
  "rules": {

    "Store01": {
            ".read": "auth != null && (root.child('readUsers').hasChild(auth.uid) || root.child('readWriteUsers').hasChild(auth.uid))",
            ".write": "auth != null && root.child('readWriteUsers').hasChild(auth.uid)"
      },

    "readUsers": {
            ".read": "auth != null && root.child('readUsers').hasChild(auth.uid)",
            ".write": false   
    },


    "readWriteUsers": {
            ".read": "auth != null && root.child('readWriteUsers').hasChild(auth.uid)",
            ".write": false   
    }

  }
}
- task-list-for-managers
   - stores
     - Store01
        - ....  
     - Store02
        - ....    
   - readUsers
     - WV0676TY67TY9: true   //user Id
     - PU8776TIU6543: true   
     - .....
   - readWriteUsers
     - BD563DHDV7669: true   //user Id
     - 87RSBE6383912: true   
     - .....
{
  "rules": {

    "stores": {
            ".read": "auth != null && (root.child('readUsers').hasChild(auth.uid) || root.child('readWriteUsers').hasChild(auth.uid))",
            ".write": "auth != null && root.child('readWriteUsers').hasChild(auth.uid)"
      },

    "readUsers": {
            ".read": "auth != null && root.child('readUsers').hasChild(auth.uid)",
            ".write": false   
    },


    "readWriteUsers": {
            ".read": "auth != null && root.child('readWriteUsers').hasChild(auth.uid)",
            ".write": false   
    }

  }
}
How to make Firebase database values only visible to their respective paired UIDs?

How to make Firebase database values only visible to their respective paired UIDs?


By : user3692643
Date : March 29 2020, 07:55 AM
will be helpful for those in need This is my database structure: , From the Firebase documentation:
code :
  "rules": {
".read": "auth.uid != null",
".write":"auth.uid != null",
{
  "rules": {
    "Users' Input History": {
      "$user": {
            ".read": "auth.uid  === $user",
              ".write": "auth.uid  === $user"
      }
    },

    "Users' Vocabulary List": {
      "$user": {
            ".read": "auth.uid  === $user",
              ".write": "auth.uid  === $user"
      }
    }
  }
}
Related Posts Related Posts :
  • How to employ keyed-hash message authentication code (HMAC) with Android Keystore
  • Prevent inviting existing users or previously invited
  • How to overwrite windowSoftInputMode using edit-config tag in cordova
  • Difference between Loader and AsyncTask
  • In Firebase Android, retrieve the value of a child node and save it in a boolean variable
  • when i scroll the custom list in my android app then the favorite icon which is part of the custom adapter changes on it
  • adding room dependency gives manifest merge error
  • Visibility of RelativeLayout change on scrolling Gridview
  • Strange LiveData behavior vs ObservableField
  • Which layout is used for clash of clans home screen? We can scroll it horizontal as well as vertical. Please illuminate
  • RxJava: Know when observable is finished and return Boolean Observable to the caller
  • how to use savedInstanceState to save camera information when the orientation change occure
  • Style React-Native via Styles.xml
  • Keyboard won't show after calling InputMethodManager.showSoftInput
  • Compiling ffmpeg for Android on OSX
  • Button does not get clicked on the first attempt
  • AR Core performance, learning curve and comparison with other frameworks
  • Codename one : Attaching images to email message fails
  • Error: Unsupported type 'viewItem' in Android build
  • setLayoutParams on ConstraintLayout does not change size
  • How to profile the fetch time of the android gradle libraries
  • Kotlin setOnclickListener
  • Naming convention for methods returning RxJava's Completable
  • Conv3D not working
  • FFmpeg audio video merge command
  • Do you have to use gradle-experimental for JNI?
  • How to get key hashes for facebook for facebook app?
  • ZXing not calling onActivityResult, When scanning QR Code
  • Integration of Android Native module with existing Xamarin Native Project
  • Restore RecyclerView state after rotating
  • ViewModelProviders java.lang.RuntimeException trying to instantiate class which inherit AndroidViewModel
  • SKD19 vs SDK24 - Usage of API documented as @since 1.8+
  • filter option in list view fragment activity
  • Picture from camera not showing up in second activity
  • How to change imageview according to screen size
  • How to copy Android Studio project to remote Git (NOT GitHub) server
  • How to get React-Native to announce specific accessibility message via AccessibiliyManager?
  • Change colors of com.tech.freak.wizardpager.ui.StepPagerStrip
  • Android fullscreen activity shows ActionBar
  • Turn on the screen when timer calls onFinish()
  • Would like a bit of clarification with SQLite database's onUpgrade method
  • Use ObjectBox with Libgdx
  • How to make combine Gregorian and Hijri calendar in Android?
  • Try to read text file from sdcard in other language
  • "App not installed" message when installed apk
  • How to execute a designated test suite class in Firebase Test Lab
  • play music with background service
  • background not visible on LG G3
  • should every View have an id?
  • Realm object server sync on low connection.
  • Correct way to add more views to adapter
  • Getting error in android support library
  • Instant app zip uploading error
  • "No emulator installed" error in Android Studio even though Intel HAXM is up and running
  • AsyncTask without leaks
  • SQLiteException : No such table found whereas a table was created
  • Using @Component.Builder with constructor params
  • No injector was found for fragment dagger 2.11
  • Android Volley Https SSL self signed and Google Maps API
  • Why does the onClickListener not work anymore in this example?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org