ইমেল অ্যাকশন লিঙ্ক তৈরি করা হচ্ছে

মোবাইল অ্যাপগুলিকে কখনও কখনও ব্যবহারকারীদের সাথে যোগাযোগ করতে হয় এবং ইমেল পাঠিয়ে তাদের নির্দিষ্ট পদক্ষেপ নিতে প্ররোচিত করতে হয়।

Firebase ক্লায়েন্ট SDK ব্যবহারকারীদের এমন লিঙ্ক সম্বলিত ইমেল পাঠানোর ক্ষমতা প্রদান করে যা তারা পাসওয়ার্ড রিসেট, ইমেল ঠিকানা যাচাইকরণ এবং ইমেল-ভিত্তিক সাইন-ইনের জন্য ব্যবহার করতে পারে। এই টেমপ্লেট-ভিত্তিক ইমেলগুলি Google দ্বারা পাঠানো হয় এবং সীমিত কাস্টমাইজেবিলিটি রয়েছে।

আপনি যদি এর পরিবর্তে আপনার নিজস্ব ইমেল টেমপ্লেট এবং আপনার নিজস্ব ইমেল ডেলিভারি পরিষেবা ব্যবহার করতে চান, তাহলে এই পৃষ্ঠাটি ব্যাখ্যা করে যে কীভাবে Firebase Admin SDK ব্যবহার করে উপরের প্রবাহগুলির জন্য প্রোগ্রাম্যাটিকভাবে অ্যাকশন লিঙ্ক তৈরি করবেন, যা আপনি আপনার ব্যবহারকারীদের ইমেলে অন্তর্ভুক্ত করতে পারেন।

এর ফলে নিম্নলিখিত সুবিধাগুলি পাওয়া যায়:

  • ইমেল টেমপ্লেট কাস্টমাইজ করুন। এর মধ্যে রয়েছে নতুন স্টাইল এবং কাস্টম ব্র্যান্ডিং যোগ করার ক্ষমতা, শব্দ এবং লোগো পরিবর্তন করা, ব্যবহারকারীদের পুরো নামের পরিবর্তে প্রথম নাম দিয়ে সম্বোধন করা ইত্যাদি।
  • প্রেক্ষাপটের উপর নির্ভর করে বিভিন্ন টেমপ্লেট প্রয়োগ করুন। উদাহরণস্বরূপ, যদি ব্যবহারকারী কোনও নিউজলেটার সাবস্ক্রাইব করার জন্য তাদের ইমেল যাচাই করেন, তাহলে ইমেল সামগ্রীতে প্রেক্ষাপট প্রদান করতে হতে পারে। আরেকটি উদাহরণ হল ইমেল লিঙ্ক সাইন ইন: একটি পরিস্থিতিতে এটি একই ব্যবহারকারী দ্বারা ট্রিগার করা হতে পারে, অথবা অন্য ব্যবহারকারী দ্বারা আমন্ত্রণ হিসাবে। প্রেক্ষাপটটি ইমেলে অন্তর্ভুক্ত করা প্রয়োজন।
  • কাস্টমাইজড ইমেল টেমপ্লেট স্থানীয়করণ করুন।
  • একটি নিরাপদ সার্ভার পরিবেশ থেকে লিঙ্ক তৈরি করার ক্ষমতা।
  • মোবাইল অ্যাপ বা ব্রাউজারের মাধ্যমে লিঙ্কটি কীভাবে খুলতে হবে এবং কীভাবে অতিরিক্ত অবস্থা সম্পর্কিত তথ্য প্রেরণ করতে হবে ইত্যাদি কাস্টমাইজ করার ক্ষমতা।
  • ইমেল অ্যাকশন লিঙ্ক তৈরি করার সময় মোবাইল অ্যাপ প্রবাহের জন্য ব্যবহৃত মোবাইল লিঙ্ক ডোমেন কাস্টমাইজ করার ক্ষমতা।

অ্যাকশনকোডসেটিংস শুরু করুন

একটি ইমেল অ্যাকশন লিঙ্ক তৈরি করার আগে, আপনাকে একটি ActionCodeSettings ইনস্ট্যান্স শুরু করতে হতে পারে।

ActionCodeSettings আপনাকে একটি Continue URL এর মাধ্যমে অতিরিক্ত অবস্থা পাস করার অনুমতি দেয় যা ব্যবহারকারী ইমেল লিঙ্কে ক্লিক করার পরে অ্যাক্সেসযোগ্য। এটি ব্যবহারকারীকে অ্যাকশন সম্পন্ন হওয়ার পরে অ্যাপে ফিরে যাওয়ার ক্ষমতাও প্রদান করে। এছাড়াও, আপনি নির্দিষ্ট করতে পারেন যে ইমেল অ্যাকশন লিঙ্কটি সরাসরি মোবাইল অ্যাপ্লিকেশন থেকে পরিচালনা করবেন নাকি ব্রাউজার থেকে।

মোবাইল অ্যাপের মাধ্যমে খোলার জন্য তৈরি লিঙ্কগুলির জন্য, আপনার মোবাইল অ্যাপ থেকে এই লিঙ্কগুলি সনাক্ত করার জন্য আপনাকে কিছু কাজ করতে হবে। ইমেল অ্যাকশনের জন্য মোবাইল লিঙ্কগুলি কীভাবে কনফিগার করবেন তার নির্দেশাবলী পড়ুন।

একটি ActionCodeSettings ইনস্ট্যান্স শুরু করতে, নিম্নলিখিত তথ্য প্রদান করুন:

প্যারামিটার আদর্শ বিবরণ
url স্ট্রিং

বিভিন্ন প্রসঙ্গে ভিন্ন ভিন্ন অর্থ বহনকারী লিঙ্ক (state/continue URL) সেট করে:

  • যখন ওয়েব অ্যাকশন উইজেটগুলিতে লিঙ্কটি পরিচালনা করা হয়, তখন এটি continueUrl কোয়েরি প্যারামিটারের ডিপ লিঙ্ক।
  • যখন লিঙ্কটি সরাসরি অ্যাপে পরিচালনা করা হয়, তখন এটি Hosting লিঙ্কের ডিপ লিঙ্কে continueUrl কোয়েরি প্যারামিটার।
iOS ({বান্ডেলআইডি: স্ট্রিং}|অনির্ধারিত) iOS বান্ডেল আইডি সেট করে যাতে Firebase Authentication নির্ধারণ করতে সাহায্য করে যে এটি একটি ওয়েব-কেবল লিঙ্ক তৈরি করবে নাকি মোবাইল লিঙ্ক তৈরি করবে যা একটি Apple ডিভাইসে খোলা হবে।
android ({প্যাকেজনাম: স্ট্রিং, ইনস্টলঅ্যাপ:বুলিয়ান|অনির্ধারিত, ন্যূনতম সংস্করণ: স্ট্রিং|অনির্ধারিত}|অনির্ধারিত) Firebase Authentication সাহায্য করার জন্য Android প্যাকেজের নাম সেট করে, যা নির্ধারণ করে যে এটি একটি ওয়েব-কেবল লিঙ্ক তৈরি করবে নাকি মোবাইল লিঙ্ক তৈরি করবে যা একটি Android ডিভাইসে খোলা হবে।
handleCodeInApp (বুলিয়ান|অনির্ধারিত) ইমেল অ্যাকশন লিঙ্কটি প্রথমে মোবাইল অ্যাপে খোলা হবে নাকি ওয়েব লিঙ্কে। ডিফল্ট হিসেবে false আছে। true হিসেবে সেট করা হলে, অ্যাকশন কোড লিঙ্কটি একটি ইউনিভার্সাল লিঙ্ক অথবা অ্যান্ড্রয়েড অ্যাপ লিঙ্ক হিসেবে পাঠানো হবে এবং ইনস্টল করা থাকলে অ্যাপটি এটি খুলবে। false ক্ষেত্রে, কোডটি প্রথমে ওয়েব উইজেটে পাঠানো হবে এবং তারপর ইনস্টল করা থাকলে অ্যাপটিতে পুনঃনির্দেশিত করা হবে।
linkDomain (স্ট্রিং|অনির্ধারিত) যখন কোনও প্রকল্পের জন্য কাস্টম হোস্টিং লিঙ্ক ডোমেনগুলি সংজ্ঞায়িত করা হয়, তখন নির্দিষ্ট মোবাইল অ্যাপ দ্বারা লিঙ্কটি খোলার সময় কোনটি ব্যবহার করবেন তা নির্দিষ্ট করুন। অন্যথায়, ডিফল্ট ডোমেনটি স্বয়ংক্রিয়ভাবে নির্বাচিত হয় (উদাহরণস্বরূপ, PROJECT_ID .firebaseapp.com )।
dynamicLinkDomain (স্ট্রিং|অনির্ধারিত) বন্ধ করা হয়েছে। এই প্যারামিটারটি নির্দিষ্ট করবেন না।

নিচের উদাহরণটি দেখায় কিভাবে একটি ইমেল যাচাইকরণ লিঙ্ক পাঠাতে হয় যা প্রথমে একটি মোবাইল অ্যাপে খুলবে। ডিপ লিঙ্কটিতে continue URL payload https://www.example.com/checkout?cartId=1234 থাকবে। ব্যবহৃত কাস্টম Hosting লিঙ্ক ডোমেইন হল custom-domain.com , যা Firebase Hosting সাথে ব্যবহারের জন্য কনফিগার করা আবশ্যক।

নোড.জেএস

const actionCodeSettings = {
  // URL you want to redirect back to. The domain (www.example.com) for
  // this URL must be whitelisted in the Firebase Console.
  url: 'https://www.example.com/checkout?cartId=1234',
  // This must be true for email link sign-in.
  handleCodeInApp: true,
  iOS: {
    bundleId: 'com.example.ios',
  },
  android: {
    packageName: 'com.example.android',
    installApp: true,
    minimumVersion: '12',
  },
  // The domain must be configured in Firebase Hosting and owned by the project.
  linkDomain: 'custom-domain.com',
};

জাভা

ActionCodeSettings actionCodeSettings = ActionCodeSettings.builder()
    .setUrl("https://www.example.com/checkout?cartId=1234")
    .setHandleCodeInApp(true)
    .setIosBundleId("com.example.ios")
    .setAndroidPackageName("com.example.android")
    .setAndroidInstallApp(true)
    .setAndroidMinimumVersion("12")
    .setDynamicLinkDomain("coolapp.page.link")
    .build();

পাইথন

action_code_settings = auth.ActionCodeSettings(
    url='https://www.example.com/checkout?cartId=1234',
    handle_code_in_app=True,
    ios_bundle_id='com.example.ios',
    android_package_name='com.example.android',
    android_install_app=True,
    android_minimum_version='12',
    dynamic_link_domain='coolapp.page.link',
)

যাও

actionCodeSettings := &auth.ActionCodeSettings{
	URL:                   "https://www.example.com/checkout?cartId=1234",
	HandleCodeInApp:       true,
	IOSBundleID:           "com.example.ios",
	AndroidPackageName:    "com.example.android",
	AndroidInstallApp:     true,
	AndroidMinimumVersion: "12",
	DynamicLinkDomain:     "coolapp.page.link",
}

সি#

var actionCodeSettings = new ActionCodeSettings()
{
    Url = "https://www.example.com/checkout?cartId=1234",
    HandleCodeInApp = true,
    IosBundleId = "com.example.ios",
    AndroidPackageName = "com.example.android",
    AndroidInstallApp = true,
    AndroidMinimumVersion = "12",
    LinkDomain = "coolapp.page.link",
};

আরও জানতে, ইমেল অ্যাকশনে পাসিং স্টেট দেখুন।

পাসওয়ার্ড রিসেট ইমেল লিঙ্ক তৈরি করুন

পাসওয়ার্ড রিসেট লিঙ্ক তৈরি করতে, বিদ্যমান ব্যবহারকারীর ইমেল এবং একটি ঐচ্ছিক ActionCodeSettings অবজেক্ট প্রদান করুন। ইমেল অ্যাকশন লিঙ্কের মাধ্যমে অপারেশনটি সমাধান হবে। ব্যবহৃত ইমেলটি অবশ্যই বিদ্যমান ব্যবহারকারীর হতে হবে।

নোড.জেএস

// Admin SDK API to generate the password reset link.
const userEmail = 'user@example.com';
getAuth()
  .generatePasswordResetLink(userEmail, actionCodeSettings)
  .then((link) => {
    // Construct password reset email template, embed the link and send
    // using custom SMTP server.
    return sendCustomPasswordResetEmail(userEmail, displayName, link);
  })
  .catch((error) => {
    // Some error occurred.
  });

জাভা

String email = "user@example.com";
try {
  String link = FirebaseAuth.getInstance().generatePasswordResetLink(
      email, actionCodeSettings);
  // Construct email verification template, embed the link and send
  // using custom SMTP server.
  sendCustomEmail(email, displayName, link);
} catch (FirebaseAuthException e) {
  System.out.println("Error generating email link: " + e.getMessage());
}

পাইথন

email = 'user@example.com'
link = auth.generate_password_reset_link(email, action_code_settings)
# Construct password reset email from a template embedding the link, and send
# using a custom SMTP server.
send_custom_email(email, link)

যাও

email := "user@example.com"
link, err := client.PasswordResetLinkWithSettings(ctx, email, actionCodeSettings)
if err != nil {
	log.Fatalf("error generating email link: %v\n", err)
}

// Construct password reset template, embed the link and send
// using custom SMTP server.
sendCustomEmail(email, displayName, link)

সি#

var email = "user@example.com";
var link = await FirebaseAuth.DefaultInstance.GeneratePasswordResetLinkAsync(
    email, actionCodeSettings);
// Construct email verification template, embed the link and send
// using custom SMTP server.
SendCustomEmail(email, displayName, link);

লিঙ্কটি তৈরি হওয়ার পর, এটি কাস্টম পাসওয়ার্ড রিসেট ইমেলে ঢোকানো যেতে পারে এবং তারপর একটি কাস্টম SMTP সার্ভার ব্যবহার করে সংশ্লিষ্ট ব্যবহারকারীর কাছে ইমেল করা যেতে পারে।

আপনি যদি ডিফল্ট পাসওয়ার্ড রিসেট ল্যান্ডিং পৃষ্ঠা ব্যবহার না করেন এবং আপনার নিজস্ব কাস্টম হ্যান্ডলার তৈরি না করেন, তাহলে কাস্টম ইমেল অ্যাকশন হ্যান্ডলার তৈরি করা দেখুন।

ইমেল যাচাইকরণ লিঙ্ক তৈরি করুন

একটি ইমেল যাচাইকরণ লিঙ্ক তৈরি করতে, বিদ্যমান ব্যবহারকারীর যাচাই না করা ইমেল এবং একটি ঐচ্ছিক ActionCodeSettings অবজেক্ট প্রদান করুন। ইমেল অ্যাকশন লিঙ্কের মাধ্যমে অপারেশনটি সমাধান হবে। ব্যবহৃত ইমেলটি অবশ্যই বিদ্যমান ব্যবহারকারীর হতে হবে।

নোড.জেএস

// Admin SDK API to generate the email verification link.
const useremail = 'user@example.com';
getAuth()
  .generateEmailVerificationLink(useremail, actionCodeSettings)
  .then((link) => {
    // Construct email verification template, embed the link and send
    // using custom SMTP server.
    return sendCustomVerificationEmail(useremail, displayName, link);
  })
  .catch((error) => {
    // Some error occurred.
  });

জাভা

String email = "user@example.com";
try {
  String link = FirebaseAuth.getInstance().generateEmailVerificationLink(
      email, actionCodeSettings);
  // Construct email verification template, embed the link and send
  // using custom SMTP server.
  sendCustomEmail(email, displayName, link);
} catch (FirebaseAuthException e) {
  System.out.println("Error generating email link: " + e.getMessage());
}

পাইথন

email = 'user@example.com'
link = auth.generate_email_verification_link(email, action_code_settings)
# Construct email from a template embedding the link, and send
# using a custom SMTP server.
send_custom_email(email, link)

যাও

email := "user@example.com"
link, err := client.EmailVerificationLinkWithSettings(ctx, email, actionCodeSettings)
if err != nil {
	log.Fatalf("error generating email link: %v\n", err)
}

// Construct email verification template, embed the link and send
// using custom SMTP server.
sendCustomEmail(email, displayName, link)

সি#

var email = "user@example.com";
var link = await FirebaseAuth.DefaultInstance.GenerateEmailVerificationLinkAsync(
    email, actionCodeSettings);
// Construct email verification template, embed the link and send
// using custom SMTP server.
SendCustomEmail(email, displayName, link);

লিঙ্কটি তৈরি হওয়ার পর, এটি কাস্টম যাচাইকরণ ইমেলে ঢোকানো যেতে পারে এবং তারপর একটি কাস্টম SMTP সার্ভার ব্যবহার করে সংশ্লিষ্ট ব্যবহারকারীকে ইমেল করা যেতে পারে।

আপনি যদি ডিফল্ট ইমেল যাচাইকরণ ল্যান্ডিং পৃষ্ঠা ব্যবহার না করেন এবং আপনার নিজস্ব কাস্টম হ্যান্ডলার তৈরি করেন, তাহলে কাস্টম ইমেল অ্যাকশন হ্যান্ডলার তৈরি করা দেখুন।

সাইন-ইনের জন্য ইমেল লিঙ্ক তৈরি করুন

ইমেল লিঙ্ক সাইন-ইনের মাধ্যমে ব্যবহারকারীদের প্রমাণীকরণ করার আগে, আপনার Firebase প্রকল্পের জন্য ইমেল লিঙ্ক সাইন-ইন সক্ষম করতে হবে।

সাইন-ইন লিঙ্ক তৈরি করতে, ব্যবহারকারীর ইমেল এবং একটি ActionCodeSettings অবজেক্ট প্রদান করুন। সাইন-ইন সম্পূর্ণ করার জন্য লিঙ্কটিতে ক্লিক করার পরে ব্যবহারকারীকে কোথায় ফেরত পাঠাতে হবে সে সম্পর্কে তথ্য প্রদানের জন্য ActionCodeSettings অবজেক্টটি এই ক্ষেত্রে প্রয়োজন। ইমেল অ্যাকশন লিঙ্কের মাধ্যমে অপারেশনটি সমাধান হবে।

পাসওয়ার্ড রিসেট এবং ইমেল যাচাইকরণের বিপরীতে, ব্যবহৃত ইমেলটি অগত্যা কোনও বিদ্যমান ব্যবহারকারীর হতে হবে না, কারণ এই অপারেশনটি ইমেল লিঙ্কের মাধ্যমে আপনার অ্যাপে নতুন ব্যবহারকারীদের সাইন আপ করতে ব্যবহার করা যেতে পারে।

নোড.জেএস

// Admin SDK API to generate the sign in with email link.
const useremail = 'user@example.com';
getAuth()
  .generateSignInWithEmailLink(useremail, actionCodeSettings)
  .then((link) => {
    // Construct sign-in with email link template, embed the link and
    // send using custom SMTP server.
    return sendSignInEmail(useremail, displayName, link);
  })
  .catch((error) => {
    // Some error occurred.
  });

জাভা

String email = "user@example.com";
try {
  String link = FirebaseAuth.getInstance().generateSignInWithEmailLink(
      email, actionCodeSettings);
  // Construct email verification template, embed the link and send
  // using custom SMTP server.
  sendCustomEmail(email, displayName, link);
} catch (FirebaseAuthException e) {
  System.out.println("Error generating email link: " + e.getMessage());
}

পাইথন

email = 'user@example.com'
link = auth.generate_sign_in_with_email_link(email, action_code_settings)
# Construct email from a template embedding the link, and send
# using a custom SMTP server.
send_custom_email(email, link)

যাও

email := "user@example.com"
link, err := client.EmailSignInLink(ctx, email, actionCodeSettings)
if err != nil {
	log.Fatalf("error generating email link: %v\n", err)
}

// Construct sign-in with email link template, embed the link and send
// using custom SMTP server.
sendCustomEmail(email, displayName, link)

সি#

var email = "user@example.com";
var link = await FirebaseAuth.DefaultInstance.GenerateSignInWithEmailLinkAsync(
    email, actionCodeSettings);
// Construct email verification template, embed the link and send
// using custom SMTP server.
SendCustomEmail(email, displayName, link);

লিঙ্কটি তৈরি হওয়ার পর, এটি কাস্টম সাইন-ইন ইমেলে ঢোকানো যেতে পারে এবং তারপর একটি কাস্টম SMTP সার্ভার ব্যবহার করে সংশ্লিষ্ট ব্যবহারকারীর কাছে ইমেল করা যেতে পারে।

ইমেল লিঙ্ক ব্যবহার করে Firebase-এর মাধ্যমে ব্যবহারকারীদের প্রমাণীকরণ সম্পর্কে আরও জানুন। এটি ব্যবহারকারীর লিঙ্কে ক্লিক করার পরে এবং অ্যাপে পুনঃনির্দেশিত হওয়ার পরে কীভাবে সাইন-ইন সম্পূর্ণ করতে হয় সে সম্পর্কে তথ্য প্রদান করতে সহায়তা করবে।