Print


By using this library, you can access your users without the need to implement In-App login. You will no longer need to send SMS or E-mail for user authentication. Leave everything to Bazaar.
You could also make use of unique User IDs for different scenarios (clearing cache, device change, etc.) or just use Bazaar in-App Storage for your users.
In the first step, Bazaar will generate a unique user ID for each app/game user. You can later access various data by requesting permission from users. Click Here for more information


Bazaar In-App Login Implementation


To start working with “BazaarAuth”, first you need to add its “Dependency” to the file: “build.gradle”

dependencies {

    implementation "com.farsitel.bazaar:auth:[latest_version]"

}

To sign in a user, create an “object” as “BazaarSignIn”:

val signInOption = BazaarSignInOptions.Builder(SignInOption.DEFAULT_SIGN_IN).build()



client = BazaarSignIn.getClient(

    context,

    signInOption

)


Once the object is created, you can redirect user to Bazaar login page with the method shown below

val intent = client.getSignInIntent()

startActivityForResult(intent, REQ_CODE)

Next, to “parse” user’s data from Bazaar, use the code below in “onActivityResult”:

val account = BazaarSignIn.getSignedInAccountFromIntent(intent)

If the user has given permission, returned “account” will not be “null” and you can read data from “account” model:
In case the user has just recently given access permission to your app, use the code below to access the latest data:

BazaarSignIn.getLastSignedInAccount(this, this,BazaarSingInCallback { response ->

        val account = response?.data

        updateUI(account)

 })

To access data using “sync” method, use the code below:

val accountResponse = BazaarSignIn.getLastSignedInAccountSync(this, this)

Attention: the method mentioned above cannot be used in “main thread”.


To show “Bazaar Login” button, use this “view” in your “XML”:

<com.farsitel.bazaar.auth.widget.LoginButton

    android:id="@+id/loginButton"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    app:size="NORMAL" />

“App size” can be “NORMAL” or “BIG”.

  • Attributes for “Login with Bazaar” Button
  • Color code: #0EA960
  • Button text: “ورود با بازار”
  • Button text color: #FFFFFF
  • Curvature: 5dp
  • Button hight: 48db
  • order: 1dp #09663A
  • Bazaar Logo size: 30dp

Attention: You can use your preferred button style based on your App’s/Game’s design and gameplay,

Bazaar In-App Storage


You can get 10Kb of exclusive space for each user with “Bazaar In-App Storage”, eliminating the need to spend on servers and other technical costs. Scores, emails, progress and all other sorts of data can be easily saved on and retrieved from Bazaar cloud servers.
With “Bazaar In-App Storage”, user experience can still be retained in cases of uninstallation, changing the device, etc.
To “save” data, use the code below:

To change “ByteArrey response” to “string”, use “toReadableString” function.
To retrieve the “saved” data, use the method shown below:

BazaarStorage.getSavedData(

                context = this@MainActivity,

                owner = this@MainActivity,

                callback = BazaarStorageCallback { response ->

                    dataTV.text = response?.data?.toReadableString()

                }

            )

To prevent “phishing” and information theft, use the code below to make sure original version of Bazaar is installed on user’s device:

BazaarClientProxy.isBazaarInstalledOnDevice(context)

Use the code below to make sure the installed Bazaar version supports “login in-App Storage”:

BazaarClientProxy.isNeededToUpdateBazaar(context)

Use this code if Bazaar is not installed on user’s device:

BazaarClientProxy.showInstallBazaarView(context)

And if the installed version of Bazaar requires an update, use the code below:

BazaarClientProxy.showUpdateBazaarView(context)

Click Here for more information.

Was this content helpful?
Write your comment here...

If you have any comment on this content or any idea to make it better, use this form to send us your comment.

Publish Date: 1400-10-25 13:11

Latest Update: 1400-10-25 16:41