Login sample with KMM and Realm

Any sample for a simple login?

@AfterFood_Contact : We have a couple of sample apps, feel free to check them out.

1 Like

Hello @Mohit_Sharma , did you used customer user data for your UserInfo?
Because my db.userInfo is always empty after making a registration:

@AfterFood_Contact : I have added tigger on user registration something like

exports = async function({user}){

    Accessing application's values:
    var x = context.values.get("value_name");

    Accessing a mongodb service:
    var collection = context.services.get("mongodb-atlas").db("dbname").collection("coll_name");
    collection.findOne({ owner_id: context.user.id }).then((doc) => {
      // do something with doc

    To call other named functions:
    var result = context.functions.execute("function_name", arg1, arg2);

    Try running in the console below.

  console.log("user calling --- " + JSON.stringify({user}));

  //Accessing a mongodb service:
    var collection = context.services.get("mongodb-atlas").db("conference-db").collection("UserInfo");
    var count = await collection.count({
      email: user.data.email

    console.log('count ---'+ count)

    if(count == 0){
      const userDoc = {
       _id: user.id,
       email: user.data.email,
       isAdmin: false,
       name: "",
       orgName: "",
       phoneNumber: null


    .then (result => {
        console.log(` document for _id: ${result}`);
      }, error => {
        console.log(`Failed to write ${error}`);

      console.log('This is a duplicate user');
      // Do nothing duplicate user

    return {user}
1 Like

Thank you for the reply!

One more thing, can I add on the registration call another parameter? Like name, phone, address, etc, currently I can pass change the mail and password:

appservice.emailPasswordAuth.registerUser(email = email, password = password)

@AfterFood_Contact: With Kotlin SDK currently, the answer is no as support for Custom data is still in development. But there is a workaround like saving the info into a collection with a function and then merging it with the user collection after user confirmation.

Thank you!

From the samples that you sent that with KMM, you use LiveData for the android version, it helps getting the object or implementing features, like already logged in feature that uses the LiveData Object.

android liveData with flow:

val userInfo: LiveData<UserInfo?> = liveData {

What I should use for the Swift?