সার্ভার থেকে বিষয়গুলি পরিচালনা করুন

ফায়ারবেস অ্যাডমিন SDK আপনাকে সার্ভারের দিক থেকে প্রাথমিক বিষয় পরিচালনার কাজগুলি সম্পাদন করতে দেয়৷ তাদের রেজিস্ট্রেশন টোকেন(গুলি) দেওয়া, আপনি সার্ভার লজিক ব্যবহার করে বাল্ক ক্লায়েন্ট অ্যাপ ইন্সট্যান্স সাবস্ক্রাইব এবং আনসাবস্ক্রাইব করতে পারেন।

আপনি যেকোন বিদ্যমান বিষয়ের ক্লায়েন্ট অ্যাপ ইনস্ট্যান্স সাবস্ক্রাইব করতে পারেন, অথবা আপনি একটি নতুন বিষয় তৈরি করতে পারেন। আপনি যখন একটি নতুন বিষয়ে একটি ক্লায়েন্ট অ্যাপ সাবস্ক্রাইব করার জন্য API ব্যবহার করেন (যেটি আপনার ফায়ারবেস প্রকল্পের জন্য ইতিমধ্যেই বিদ্যমান নেই), তখন সেই নামের একটি নতুন বিষয় FCM-এ তৈরি হয় এবং যেকোনো ক্লায়েন্ট পরবর্তীতে এটিতে সদস্যতা নিতে পারে।

আপনি একটি বিষয়ের সাথে সংশ্লিষ্ট ডিভাইসগুলি সাবস্ক্রাইব করতে Firebase অ্যাডমিন SDK সদস্যতা পদ্ধতিতে নিবন্ধন টোকেনগুলির একটি তালিকা পাঠাতে পারেন:

Node.js

// These registration tokens come from the client FCM SDKs.
const registrationTokens = [
  'YOUR_REGISTRATION_TOKEN_1',
  // ...
  'YOUR_REGISTRATION_TOKEN_n'
];

// Subscribe the devices corresponding to the registration tokens to the
// topic.
getMessaging().subscribeToTopic(registrationTokens, topic)
  .then((response) => {
    // See the MessagingTopicManagementResponse reference documentation
    // for the contents of response.
    console.log('Successfully subscribed to topic:', response);
  })
  .catch((error) => {
    console.log('Error subscribing to topic:', error);
  });

জাভা

// These registration tokens come from the client FCM SDKs.
List<String> registrationTokens = Arrays.asList(
    "YOUR_REGISTRATION_TOKEN_1",
    // ...
    "YOUR_REGISTRATION_TOKEN_n"
);

// Subscribe the devices corresponding to the registration tokens to the
// topic.
TopicManagementResponse response = FirebaseMessaging.getInstance().subscribeToTopic(
    registrationTokens, topic);
// See the TopicManagementResponse reference documentation
// for the contents of response.
System.out.println(response.getSuccessCount() + " tokens were subscribed successfully");

পাইথন

# These registration tokens come from the client FCM SDKs.
registration_tokens = [
    'YOUR_REGISTRATION_TOKEN_1',
    # ...
    'YOUR_REGISTRATION_TOKEN_n',
]

# Subscribe the devices corresponding to the registration tokens to the
# topic.
response = messaging.subscribe_to_topic(registration_tokens, topic)
# See the TopicManagementResponse reference documentation
# for the contents of response.
print(response.success_count, 'tokens were subscribed successfully')

যাওয়া

// These registration tokens come from the client FCM SDKs.
registrationTokens := []string{
	"YOUR_REGISTRATION_TOKEN_1",
	// ...
	"YOUR_REGISTRATION_TOKEN_n",
}

// Subscribe the devices corresponding to the registration tokens to the
// topic.
response, err := client.SubscribeToTopic(ctx, registrationTokens, topic)
if err != nil {
	log.Fatalln(err)
}
// See the TopicManagementResponse reference documentation
// for the contents of response.
fmt.Println(response.SuccessCount, "tokens were subscribed successfully")

সি#

// These registration tokens come from the client FCM SDKs.
var registrationTokens = new List<string>()
{
    "YOUR_REGISTRATION_TOKEN_1",
    // ...
    "YOUR_REGISTRATION_TOKEN_n",
};

// Subscribe the devices corresponding to the registration tokens to the
// topic
var response = await FirebaseMessaging.DefaultInstance.SubscribeToTopicAsync(
    registrationTokens, topic);
// See the TopicManagementResponse reference documentation
// for the contents of response.
Console.WriteLine($"{response.SuccessCount} tokens were subscribed successfully");

অ্যাডমিন FCM API আপনাকে উপযুক্ত পদ্ধতিতে নিবন্ধন টোকেন পাস করে একটি বিষয় থেকে ডিভাইসগুলি আনসাবস্ক্রাইব করার অনুমতি দেয়:

Node.js

// These registration tokens come from the client FCM SDKs.
const registrationTokens = [
  'YOUR_REGISTRATION_TOKEN_1',
  // ...
  'YOUR_REGISTRATION_TOKEN_n'
];

// Unsubscribe the devices corresponding to the registration tokens from
// the topic.
getMessaging().unsubscribeFromTopic(registrationTokens, topic)
  .then((response) => {
    // See the MessagingTopicManagementResponse reference documentation
    // for the contents of response.
    console.log('Successfully unsubscribed from topic:', response);
  })
  .catch((error) => {
    console.log('Error unsubscribing from topic:', error);
  });

জাভা

// These registration tokens come from the client FCM SDKs.
List<String> registrationTokens = Arrays.asList(
    "YOUR_REGISTRATION_TOKEN_1",
    // ...
    "YOUR_REGISTRATION_TOKEN_n"
);

// Unsubscribe the devices corresponding to the registration tokens from
// the topic.
TopicManagementResponse response = FirebaseMessaging.getInstance().unsubscribeFromTopic(
    registrationTokens, topic);
// See the TopicManagementResponse reference documentation
// for the contents of response.
System.out.println(response.getSuccessCount() + " tokens were unsubscribed successfully");

পাইথন

# These registration tokens come from the client FCM SDKs.
registration_tokens = [
    'YOUR_REGISTRATION_TOKEN_1',
    # ...
    'YOUR_REGISTRATION_TOKEN_n',
]

# Unubscribe the devices corresponding to the registration tokens from the
# topic.
response = messaging.unsubscribe_from_topic(registration_tokens, topic)
# See the TopicManagementResponse reference documentation
# for the contents of response.
print(response.success_count, 'tokens were unsubscribed successfully')

যাওয়া

// These registration tokens come from the client FCM SDKs.
registrationTokens := []string{
	"YOUR_REGISTRATION_TOKEN_1",
	// ...
	"YOUR_REGISTRATION_TOKEN_n",
}

// Unsubscribe the devices corresponding to the registration tokens from
// the topic.
response, err := client.UnsubscribeFromTopic(ctx, registrationTokens, topic)
if err != nil {
	log.Fatalln(err)
}
// See the TopicManagementResponse reference documentation
// for the contents of response.
fmt.Println(response.SuccessCount, "tokens were unsubscribed successfully")

সি#

// These registration tokens come from the client FCM SDKs.
var registrationTokens = new List<string>()
{
    "YOUR_REGISTRATION_TOKEN_1",
    // ...
    "YOUR_REGISTRATION_TOKEN_n",
};

// Unsubscribe the devices corresponding to the registration tokens from the
// topic
var response = await FirebaseMessaging.DefaultInstance.UnsubscribeFromTopicAsync(
    registrationTokens, topic);
// See the TopicManagementResponse reference documentation
// for the contents of response.
Console.WriteLine($"{response.SuccessCount} tokens were unsubscribed successfully");

subscribeToTopic() এবং unsubscribeFromTopic() পদ্ধতির ফলে FCM থেকে প্রতিক্রিয়া সম্বলিত একটি বস্তু তৈরি হয়। অনুরোধে উল্লেখ করা নিবন্ধন টোকেনের সংখ্যা নির্বিশেষে রিটার্নের ধরন একই বিন্যাসে রয়েছে।

একটি ত্রুটির ক্ষেত্রে (প্রমাণিকরণ ব্যর্থতা, অবৈধ টোকেন বা বিষয় ইত্যাদি) এই পদ্ধতিগুলি একটি ত্রুটির কারণ হয়৷ বিবরণ এবং রেজোলিউশন পদক্ষেপ সহ ত্রুটি কোডগুলির একটি সম্পূর্ণ তালিকার জন্য, অ্যাডমিন FCM API ত্রুটিগুলি দেখুন৷