পাসওয়ার্ডের জন্য Smart Lock, যা ২০২২ সালে বন্ধ করে দেওয়া হয়েছে, সেটি এখন
Google Play Services Auth SDK
(com.google.android.gms:play-services-auth) থেকে সরিয়ে দেওয়া হয়েছে। আগে থেকে থাকা ইন্টিগ্রেশনকে প্রভাবিত করতে পারে এমন ব্রেকিং পরিবর্তন
কমাতে, Play Store-এ আগে থেকে থাকা সব অ্যাপের জন্য
Smart Lock-এর ক্ষমতা সঠিকভাবে কাজ করা চালিয়ে যাবে। আপডেট করা SDK
(com.google.android.gms:play-services-auth:21.0.0) দিয়ে কম্পাইল করা নতুন অ্যাপ ভার্সন
আর পাসওয়ার্ডের জন্য Smart Lock API অ্যাক্সেস করতে
পারবে না এবং সফলভাবে বিল্ড হবে না। সব
ডেভেলপারকে যত তাড়াতাড়ি সম্ভব ক্রেডেনশিয়াল ম্যানেজার ব্যবহার করার জন্য
তাদের Android প্রোজেক্ট মাইগ্রেট করতে হবে।
ক্রেডেনশিয়াল ম্যানেজার API-তে মাইগ্রেট করার সুবিধা
ক্রেডেনশিয়াল ম্যানেজার একটি স্ট্রিমলাইনড, ইউনিফায়েড API অফার করে যা আধুনিক ফিচার ও অনুশীলনের জন্য সহায়তা প্রদান করে এবং একই সাথে আপনার ব্যবহারকারীদের জন্য যাচাইকরণের অভিজ্ঞতা উন্নত করে:
- ক্রেডেনশিয়াল ম্যানেজার সম্পূর্ণভাবে পাসওয়ার্ড সেভ করা ও যাচাইকরণ সমর্থন করে। এর অর্থ হল, আপনার অ্যাপ Smart Lock থেকে ক্রেডেনশিয়াল ম্যানেজারে মাইগ্রেট করার সময় ব্যবহারকারীদের কোনও বাধা পেতে হবে না।
- ক্রেডেনশিয়াল ম্যানেজার একাধিক সাইন-ইন পদ্ধতির জন্য সহায়তা ইন্টিগ্রেট করে, যার মধ্যে পাসকী এবং Google-এর মাধ্যমে সাইন-ইন করুন-এর মতো ফেডারেটেড সাইন-ইন পদ্ধতি অন্তর্ভুক্ত, যাতে নিরাপত্তা বাড়ানো যায় এবং ভবিষ্যতে আপনি এর মধ্যে কোনও একটিকে সহায়তা করার পরিকল্পনা করলে কনভার্সন চালু করা যায়।
- Android 14 থেকে শুরু করে, ক্রেডেনশিয়াল ম্যানেজার থার্ড-পার্টি পাসওয়ার্ড ও পাসকী প্রদানকারীকে সাপোর্ট করে।
- ক্রেডেনশিয়াল ম্যানেজার সব যাচাইকরণ পদ্ধতি জুড়ে একটি সামঞ্জস্যপূর্ণ, ইউনিফায়েড ব্যবহারকারীর অভিজ্ঞতা প্রদান করে।
মাইগ্রেশনের বিকল্প:
| ব্যবহারের উদাহরণ | সাজেশন |
|---|---|
| পাসওয়ার্ড সেভ করা এবং সেভ করা পাসওয়ার্ড দিয়ে সাইন-ইন করা | ক্রেডেনশিয়াল ম্যানেজারের মাধ্যমে আপনার ব্যবহারকারীকে সাইন-ইন করান গাইড থেকে পাসওয়ার্ড বিকল্প ব্যবহার করুন। পাসওয়ার্ড সেভ করা ও যাচাইকরণের বিস্তারিত ধাপ পরে বর্ণনা করা হয়েছে। |
| Google-এর মাধ্যমে সাইন-ইন করুন | Google-এর মাধ্যমে সাইন-ইন করুন ফিচারের সাথে ক্রেডেনশিয়াল ম্যানেজার ইন্টিগ্রেট করুন নির্দেশিকা অনুসরণ করুন। |
| ব্যবহারকারীদের ফোন নম্বর সংক্রান্ত ইঙ্গিত দেখান | Google Identity Services থেকে ফোন নম্বর হিন্ট API ব্যবহার করুন। |
ক্রেডেনশিয়াল ম্যানেজার ব্যবহার করে পাসওয়ার্ড দিয়ে সাইন-ইন করা
ক্রেডেনশিয়াল ম্যানেজার API ব্যবহার করতে, ক্রেডেনশিয়াল ম্যানেজার গাইডের প্রয়োজনীয়তা বিভাগে উল্লেখ করা ধাপগুলি সম্পূর্ণ করুন এবং নিম্নলিখিত কাজগুলি করেছেন কিনা তা নিশ্চিত করুন:
- প্রয়োজনীয় ডিপেন্ডেন্সি যোগ করুন
- ProGuard ফাইলে ক্লাস প্রিজার্ভ করা
- ডিজিটাল অ্যাসেট লিঙ্কের জন্য সহায়তা যোগ করুন (আপনি পাসওয়ার্ডের জন্য Smart Lock ব্যবহার করলে এই ধাপটি আগে থেকেই প্রয়োগ করা হয়ে থাকবে)
- ক্রেডেনশিয়াল ম্যানেজার কনফিগার করুন
- ক্রেডেনশিয়াল ফিল্ড নির্দেশ করা
- ব্যবহারকারীর পাসওয়ার্ড সেভ করা
সেভ করা পাসওয়ার্ড দিয়ে সাইন-ইন করুন
ব্যবহারকারীর অ্যাকাউন্টের সাথে যুক্ত পাসওয়ার্ড বিকল্প ফিরিয়ে আনতে, এইসব ধাপ সম্পূর্ণ করুন:
১. পাসওয়ার্ড ও যাচাইকরণ বিকল্প শুরু করুন
// Retrieves the user's saved password for your app from their
// password provider.
val getPasswordOption = GetPasswordOption()
২. সাইন-ইন অনুরোধ তৈরি করতে আগের ধাপ থেকে পাওয়া বিকল্পগুলি ব্যবহার করুন
val getCredRequest = GetCredentialRequest(
listOf(getPasswordOption)
)
৩. সাইন-ইন ফ্লো চালু করুন
fun launchSignInFlow() {
coroutineScope.launch {
try {
// Attempt to retrieve the credential from the Credential Manager.
val result = credentialManager.getCredential(
// Use an activity-based context to avoid undefined system UI
// launching behavior.
context = activityContext,
request = getCredRequest
)
// Process the successfully retrieved credential.
handleSignIn(result)
} catch (e: GetCredentialException) {
// Handle any errors that occur during the credential retrieval
// process.
handleFailure(e)
}
}
}
private fun handleSignIn(result: GetCredentialResponse) {
// Extract the credential from the response.
val credential = result.credential
// Determine the type of credential and handle it accordingly.
when (credential) {
is PasswordCredential -> {
val username = credential.id
val password = credential.password
// Use the extracted username and password to perform
// authentication.
}
else -> {
// Handle unrecognized credential types.
Log.e(TAG, "Unexpected type of credential")
}
}
}
private fun handleFailure(e: GetCredentialException) {
// Handle specific credential retrieval errors.
when (e) {
is GetCredentialCancellationException -> {
/* This exception is thrown when the user intentionally cancels
the credential retrieval operation. Update the application's state
accordingly. */
}
is GetCredentialCustomException -> {
/* This exception is thrown when a custom error occurs during the
credential retrieval flow. Refer to the documentation of the
third-party SDK used to create the GetCredentialRequest for
handling this exception. */
}
is GetCredentialInterruptedException -> {
/* This exception is thrown when an interruption occurs during the
credential retrieval flow. Determine whether to retry the
operation or proceed with an alternative authentication method. */
}
is GetCredentialProviderConfigurationException -> {
/* This exception is thrown when there is a mismatch in
configurations for the credential provider. Verify that the
provider dependency is included in the manifest and that the
required system services are enabled. */
}
is GetCredentialUnknownException -> {
/* This exception is thrown when the credential retrieval
operation fails without providing any additional details. Handle
the error appropriately based on the application's context. */
}
is GetCredentialUnsupportedException -> {
/* This exception is thrown when the device does not support the
Credential Manager feature. Inform the user that credential-based
authentication is unavailable and guide them to an alternative
authentication method. */
}
is NoCredentialException -> {
/* This exception is thrown when there are no viable credentials
available for the user. Prompt the user to sign up for an account
or provide an alternative authentication method. Upon successful
authentication, store the login information using
androidx.credentials.CredentialManager.createCredential to
facilitate easier sign-in the next time. */
}
else -> {
// Handle unexpected exceptions.
Log.w(TAG, "Unexpected exception type: ${e::class.java.name}")
}
}
}
অতিরিক্ত রিসোর্স
- ক্রেডেনশিয়াল ম্যানেজার স্যাম্পেল রেফারেন্স
- Credential Manager কোডল্যাব
- ক্রেডেনশিয়াল ম্যানেজারের মাধ্যমে আপনার ব্যবহারকারীকে সাইন-ইন করান