Apple प्लैटफ़ॉर्म पर मौजूद एक से ज़्यादा डिवाइसों पर मैसेज भेजना

एक मैसेज को कई डिवाइसों पर टारगेट करने के लिए, विषय के हिसाब से मैसेज भेजने की सुविधा का इस्तेमाल करें. इस सुविधा की मदद से, किसी विषय के लिए ऑप्ट-इन करने वाले कई डिवाइसों पर मैसेज भेजा जा सकता है.

इस ट्यूटोरियल में, FCM के लिए Admin SDK या REST API का इस्तेमाल करके, अपने ऐप्लिकेशन सर्वर से विषय के हिसाब से मैसेज भेजने के बारे में बताया गया है. साथ ही, Apple ऐप्लिकेशन में उन्हें पाने और मैनेज करने के बारे में बताया गया है. इस पेज पर, सेटअप से लेकर पुष्टि करने तक, इन सभी चरणों के बारे में बताया गया है. इसलिए, ऐसा हो सकता है कि इसमें वे चरण भी शामिल हों जिन्हें आपने पहले ही पूरा कर लिया हो. ऐसा तब होता है, जब आपने FCM के लिए Apple क्लाइंट ऐप्लिकेशन सेट अप किया हो या पहला मैसेज भेजने के चरणों को पूरा किया हो.

अपने Apple प्रोजेक्ट में Firebase जोड़ना

इस सेक्शन में उन टास्क के बारे में बताया गया है जिन्हें आपने शायद तब पूरा कर लिया हो, जब आपने अपने ऐप्लिकेशन के लिए Firebase की अन्य सुविधाएं पहले ही चालू कर ली हों. FCM के लिए, आपको APNs की पुष्टि करने वाली कुंजी अपलोड करनी होगी और रिमोट सूचनाओं के लिए रजिस्टर करना होगा.

ज़रूरी शर्तें

  • इन्हें इंस्टॉल करें:

    • Xcode 16.2 या उसके बाद का वर्शन
  • पक्का करें कि आपका प्रोजेक्ट इन ज़रूरी शर्तों को पूरा करता हो:

    • आपका प्रोजेक्ट, इन प्लैटफ़ॉर्म वर्शन या इसके बाद के वर्शन को टारगेट करना चाहिए:
      • iOS 13
      • macOS 10.15
      • tvOS 13
      • watchOS 7
  • अपने ऐप्लिकेशन को चलाने के लिए, Apple का कोई फ़िज़िकल डिवाइस सेट अप करें. इसके बाद, ये टास्क पूरे करें:

    • अपने Apple Developer खाते के लिए, Apple Push Notification Authentication Key पाएं.
    • ऐप्लिकेशन > क्षमताएं में जाकर, XCode में पुश नोटिफ़िकेशन चालू करें.

अगर आपके पास पहले से कोई Xcode प्रोजेक्ट नहीं है और आपको सिर्फ़ Firebase प्रॉडक्ट आज़माना है, तो हमारे क्विकस्टार्ट सैंपल में से कोई एक डाउनलोड करें.

Firebase प्रोजेक्ट बनाना

अपने Apple ऐप्लिकेशन में Firebase जोड़ने से पहले, आपको एक Firebase प्रोजेक्ट बनाना होगा, ताकि उसे अपने ऐप्लिकेशन से कनेक्ट किया जा सके. Firebase प्रोजेक्ट के बारे में ज़्यादा जानने के लिए, Firebase प्रोजेक्ट के बारे में जानकारी पर जाएं.

अपने ऐप्लिकेशन को Firebase के साथ रजिस्टर करना

Apple ऐप्लिकेशन में Firebase का इस्तेमाल करने के लिए, आपको अपने ऐप्लिकेशन को Firebase प्रोजेक्ट में रजिस्टर करना होगा. ऐप्लिकेशन रजिस्टर करने को अक्सर, अपने प्रोजेक्ट में ऐप्लिकेशन "जोड़ना" कहा जाता है.

  1. Firebase कंसोल पर जाएं.

  2. सेटअप वर्कफ़्लो लॉन्च करने के लिए, प्रोजेक्ट की खास जानकारी वाले पेज के बीच में मौजूद iOS+ आइकॉन पर क्लिक करें.

    अगर आपने पहले ही अपने Firebase प्रोजेक्ट में कोई ऐप्लिकेशन जोड़ लिया है, तो प्लैटफ़ॉर्म के विकल्प देखने के लिए, ऐप्लिकेशन जोड़ें पर क्लिक करें.

  3. बंडल आईडी फ़ील्ड में, अपने ऐप्लिकेशन का बंडल आईडी डालें.

  4. (ज़रूरी नहीं) ऐप्लिकेशन की अन्य जानकारी डालें: ऐप्लिकेशन का निकनेम और App Store आईडी.

  5. ऐप्लिकेशन रजिस्टर करें पर क्लिक करें.

Firebase कॉन्फ़िगरेशन फ़ाइल जोड़ना

  1. अपने ऐप्लिकेशन की Firebase कॉन्फ़िगरेशन फ़ाइल (GoogleService-Info.plist) पाने के लिए, GoogleService-Info.plist डाउनलोड करें पर क्लिक करें.

  2. अपनी कॉन्फ़िगरेशन फ़ाइल को Xcode प्रोजेक्ट के रूट में ले जाएं. अगर आपसे कहा जाए, तो सभी टारगेट में कॉन्फ़िग फ़ाइल जोड़ने का विकल्प चुनें.

अगर आपके प्रोजेक्ट में एक से ज़्यादा बंडल आईडी हैं, तो आपको हर बंडल आईडी को Firebase कंसोल में रजिस्टर किए गए ऐप्लिकेशन से जोड़ना होगा. इससे हर ऐप्लिकेशन के पास अपनी GoogleService-Info.plist फ़ाइल होगी.

अपने ऐप्लिकेशन में Firebase SDK टूल जोड़ना

Firebase डिपेंडेंसी इंस्टॉल और मैनेज करने के लिए, Swift Package Manager का इस्तेमाल करें.

  1. Xcode में, अपने ऐप्लिकेशन प्रोजेक्ट को खोलें. इसके बाद, File > Add Packages पर जाएं.
  2. जब आपसे कहा जाए, तब Firebase Apple प्लैटफ़ॉर्म SDK टूल की रिपॉज़िटरी जोड़ें:
  3.   https://github.com/firebase/firebase-ios-sdk.git
  4. Firebase Cloud Messaging लाइब्रेरी चुनें.
  5. टारगेट की बिल्ड सेटिंग के Other Linker Flags सेक्शन में -ObjC फ़्लैग जोड़ें.
  6. Firebase Cloud Messaging का बेहतर तरीके से इस्तेमाल करने के लिए, हमारा सुझाव है कि आप अपने Firebase प्रोजेक्ट में Google Analytics चालू करें. साथ ही, अपने ऐप्लिकेशन में Google Analytics के लिए Firebase SDK टूल जोड़ें. आपके पास, आईडीएफ़ए इकट्ठा करने की सुविधा के बिना या आईडीएफ़ए इकट्ठा करने की सुविधा के साथ लाइब्रेरी चुनने का विकल्प होता है. Firebase SDK के लिए Google Analytics में मॉड्यूल के नए संगठन के बारे में अक्सर पूछे जाने वाले सवाल देखें.
  7. इसके बाद, Xcode आपके पैकेज की डिपेंडेंसी से जुड़ी समस्या को हल करना शुरू कर देगा और उन्हें बैकग्राउंड में डाउनलोड करेगा.

APNs की पुष्टि करने वाली कुंजी अपलोड करना

APNs की पुष्टि करने वाली कुंजी को Firebase पर अपलोड करें. अगर आपके पास पहले से APNs की पुष्टि करने वाला कोई कुंजी नहीं है, तो Apple Developer Member Center में जाकर, एक कुंजी बनाएं.

  1. Firebase कंसोल में अपने प्रोजेक्ट में जाकर, गियर आइकॉन चुनें. इसके बाद, प्रोजेक्ट की सेटिंग चुनें. इसके बाद, Cloud Messaging टैब चुनें.

  2. iOS ऐप्लिकेशन कॉन्फ़िगरेशन में जाकर, APNs ऑथेंटिकेशन कुंजी में मौजूद, अपलोड करें बटन पर क्लिक करें.

  3. उस जगह पर जाएं जहां आपने अपनी कुंजी सेव की है. उसे चुनें और खोलें पर क्लिक करें. कुंजी के लिए कुंजी आईडी जोड़ें. यह Apple Developer Member Center में उपलब्ध है. इसके बाद, अपलोड करें पर क्लिक करें.

अपने ऐप्लिकेशन में Firebase को चालू करना

आपको अपने ऐप्लिकेशन में Firebase को शुरू करने वाला कोड जोड़ना होगा. Firebase मॉड्यूल इंपोर्ट करें और शेयर किए गए इंस्टेंस को इस तरह कॉन्फ़िगर करें:

  1. अपने UIApplicationDelegate में FirebaseCore मॉड्यूल के साथ-साथ, ऐप्लिकेशन डेलिगेट इस्तेमाल करने वाले अन्य Firebase मॉड्यूल इंपोर्ट करें. उदाहरण के लिए, Cloud Firestore और Authentication का इस्तेमाल करने के लिए:

    SwiftUI

    import SwiftUI
    import FirebaseCore
    import FirebaseFirestore
    import FirebaseAuth
    // ...
          

    Swift

    import FirebaseCore
    import FirebaseFirestore
    import FirebaseAuth
    // ...
          

    Objective-C

    @import FirebaseCore;
    @import FirebaseFirestore;
    @import FirebaseAuth;
    // ...
          
  2. अपने ऐप्लिकेशन डेलिगेट के application(_:didFinishLaunchingWithOptions:) तरीके में, शेयर किए गए इंस्टेंस FirebaseApp को कॉन्फ़िगर करें:

    SwiftUI

    // Use Firebase library to configure APIs
    FirebaseApp.configure()

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()

    Objective-C

    // Use Firebase library to configure APIs
    [FIRApp configure];
  3. अगर SwiftUI का इस्तेमाल किया जा रहा है, तो आपको एक ऐप्लिकेशन डेलिगेट बनाना होगा. साथ ही, इसे UIApplicationDelegateAdaptor या NSApplicationDelegateAdaptor के ज़रिए अपनी App स्ट्रक्चर से जोड़ना होगा. आपको ऐप्लिकेशन के डेलिगेट स्विज़लिंग को भी बंद करना होगा. ज़्यादा जानकारी के लिए, SwiftUI के निर्देश देखें.

    SwiftUI

    @main
    struct YourApp: App {
      // register app delegate for Firebase setup
      @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
    
      var body: some Scene {
        WindowGroup {
          NavigationView {
            ContentView()
          }
        }
      }
    }
          

रिमोट सूचनाओं के लिए रजिस्टर करना

ऐप्लिकेशन के शुरू होने पर या ऐप्लिकेशन के फ़्लो में अपनी पसंद के पॉइंट पर, रिमोट सूचनाओं के लिए अपना ऐप्लिकेशन रजिस्टर करें. registerForRemoteNotifications को इस तरह कॉल करें:

Swift

UNUserNotificationCenter.current().delegate = self

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
  options: authOptions,
  completionHandler: { _, _ in }
)

application.registerForRemoteNotifications()

Objective-C

[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
    UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter]
    requestAuthorizationWithOptions:authOptions
    completionHandler:^(BOOL granted, NSError * _Nullable error) {
      // ...
    }];

[application registerForRemoteNotifications];

क्लाइंट ऐप्लिकेशन को किसी विषय की सदस्यता लेना

क्लाइंट ऐप्लिकेशन, किसी भी मौजूदा विषय की सदस्यता ले सकते हैं या वे कोई नया विषय बना सकते हैं. जब कोई क्लाइंट ऐप्लिकेशन, किसी नए विषय के नाम की सदस्यता लेता है (ऐसा नाम जो आपके Firebase प्रोजेक्ट के लिए पहले से मौजूद नहीं है), तो उस नाम का एक नया विषय FCM में बन जाता है. इसके बाद, कोई भी क्लाइंट उसकी सदस्यता ले सकता है.

किसी विषय की सदस्यता लेने के लिए, अपने ऐप्लिकेशन की मुख्य थ्रेड से सदस्यता लेने के तरीके को कॉल करें (FCM थ्रेड-सेफ़ नहीं है). अगर सदस्यता का अनुरोध शुरू में पूरा नहीं होता है, तो FCM अपने-आप फिर से कोशिश करता है. अगर सदस्यता नहीं ली जा सकती, तो सदस्यता लेने की प्रोसेस में गड़बड़ी होती है. इस गड़बड़ी को पूरा होने वाले हैंडलर में पकड़ा जा सकता है. यहां दिखाया गया है:

Swift

Messaging.messaging().subscribe(toTopic: "weather") { error in
  print("Subscribed to weather topic")
}

Objective-C

[[FIRMessaging messaging] subscribeToTopic:@"weather"
                                completion:^(NSError * _Nullable error) {
  NSLog(@"Subscribed to weather topic");
}];

यह कॉल, FCM के बैकएंड को एसिंक्रोनस अनुरोध करता है. साथ ही, क्लाइंट को दिए गए विषय की सदस्यता लेता है. subscribeToTopic:topic को कॉल करने से पहले, पक्का करें कि क्लाइंट ऐप्लिकेशन इंस्टेंस को didReceiveRegistrationToken कॉलबैक के ज़रिए, रजिस्ट्रेशन टोकन पहले ही मिल चुका हो.

ऐप्लिकेशन के शुरू होने पर, FCM यह पक्का करता है कि अनुरोध किए गए सभी विषयों की सदस्यता ली गई हो. सदस्यता छोड़ने के लिए, unsubscribeFromTopic:topic पर कॉल करें. इसके बाद, FCM बैकग्राउंड में विषय की सदस्यता छोड़ देगा.

विषय के हिसाब से मैसेज पाना और उन्हें मैनेज करना

FCM विषय के मैसेज उसी तरह डिलीवर करता है जिस तरह अन्य डाउनस्ट्रीम मैसेज डिलीवर किए जाते हैं.

application(_:didReceiveRemoteNotification:fetchCompletionHandler:) को इस तरह लागू करें:

Swift

func application(_ application: UIApplication,
                 didReceiveRemoteNotification userInfo: [AnyHashable: Any]) async
  -> UIBackgroundFetchResult {
  // If you are receiving a notification message while your app is in the background,
  // this callback will not be fired till the user taps on the notification launching the application.
  // TODO: Handle data of notification

  // With swizzling disabled you must let Messaging know about the message, for Analytics
  // Messaging.messaging().appDidReceiveMessage(userInfo)

  // Print message ID.
  if let messageID = userInfo[gcmMessageIDKey] {
    print("Message ID: \(messageID)")
  }

  // Print full message.
  print(userInfo)

  return UIBackgroundFetchResult.newData
}

Objective-C

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  // If you are receiving a notification message while your app is in the background,
  // this callback will not be fired till the user taps on the notification launching the application.
  // TODO: Handle data of notification

  // With swizzling disabled you must let Messaging know about the message, for Analytics
  // [[FIRMessaging messaging] appDidReceiveMessage:userInfo];

  // ...

  // Print full message.
  NSLog(@"%@", userInfo);

  completionHandler(UIBackgroundFetchResultNewData);
}

अनुरोध भेजने की सुविधा बनाना

विषय बनाने के बाद, उस विषय पर मैसेज भेजे जा सकते हैं. विषय बनाने के लिए, क्लाइंट ऐप्लिकेशन के इंस्टेंस को क्लाइंट साइड पर विषय की सदस्यता लें या सर्वर एपीआई का इस्तेमाल करें. अगर आपको FCM के लिए पहली बार अनुरोध भेजने हैं, तो आपके सर्वर एनवायरमेंट और FCM के बारे में जानकारी देने वाली गाइड देखें. इसमें बैकग्राउंड और सेटअप से जुड़ी ज़रूरी जानकारी दी गई है.

बैकएंड पर, मैसेज भेजने के लॉजिक में, विषय का नाम इस तरह डालें:

Node.js

// The topic name can be optionally prefixed with "/topics/".
const topic = 'highScores';

const message = {
  data: {
    score: '850',
    time: '2:45'
  },
  topic: topic
};

// Send a message to devices subscribed to the provided topic.
getMessaging().send(message)
  .then((response) => {
    // Response is a message ID string.
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

Java

// The topic name can be optionally prefixed with "/topics/".
String topic = "highScores";

// See documentation on defining a message payload.
Message message = Message.builder()
    .putData("score", "850")
    .putData("time", "2:45")
    .setTopic(topic)
    .build();

// Send a message to the devices subscribed to the provided topic.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);

Python

# The topic name can be optionally prefixed with "/topics/".
topic = 'highScores'

# See documentation on defining a message payload.
message = messaging.Message(
    data={
        'score': '850',
        'time': '2:45',
    },
    topic=topic,
)

# Send a message to the devices subscribed to the provided topic.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)

शुरू करें

// The topic name can be optionally prefixed with "/topics/".
topic := "highScores"

// See documentation on defining a message payload.
message := &messaging.Message{
	Data: map[string]string{
		"score": "850",
		"time":  "2:45",
	},
	Topic: topic,
}

// Send a message to the devices subscribed to the provided topic.
response, err := client.Send(ctx, message)
if err != nil {
	log.Fatalln(err)
}
// Response is a message ID string.
fmt.Println("Successfully sent message:", response)

C#

// The topic name can be optionally prefixed with "/topics/".
var topic = "highScores";

// See documentation on defining a message payload.
var message = new Message()
{
    Data = new Dictionary<string, string>()
    {
        { "score", "850" },
        { "time", "2:45" },
    },
    Topic = topic,
};

// Send a message to the devices subscribed to the provided topic.
string response = await FirebaseMessaging.DefaultInstance.SendAsync(message);
// Response is a message ID string.
Console.WriteLine("Successfully sent message: " + response);

REST

POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA
{
  "message":{
    "topic" : "foo-bar",
    "notification" : {
      "body" : "This is a Firebase Cloud Messaging Topic Message!",
      "title" : "FCM Message"
      }
   }
}

cURL कमांड:

curl -X POST -H "Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA" -H "Content-Type: application/json" -d '{
  "message": {
    "topic" : "foo-bar",
    "notification": {
      "body": "This is a Firebase Cloud Messaging Topic Message!",
      "title": "FCM Message"
    }
  }
}' https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

विषयों के कॉम्बिनेशन को मैसेज भेजने के लिए, शर्त तय करें. यह एक बूलियन एक्सप्रेशन होता है, जो टारगेट किए गए विषयों के बारे में बताता है. उदाहरण के लिए, यहां दी गई शर्त के हिसाब से, उन डिवाइसों को मैसेज भेजे जाएंगे जिन्होंने TopicA और TopicB या TopicC की सदस्यता ली है:

"'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)"

FCM सबसे पहले, ब्रैकेट में दी गई शर्तों का आकलन करता है. इसके बाद, एक्सप्रेशन का आकलन बाएं से दाएं करता है. ऊपर दिए गए एक्सप्रेशन में, किसी एक विषय की सदस्यता लेने वाले उपयोगकर्ता को मैसेज नहीं मिलता. इसी तरह, TopicA की सदस्यता न लेने वाले उपयोगकर्ता को मैसेज नहीं मिलता. इन कॉम्बिनेशन को यह सुविधा मिलती है:

  • TopicA और TopicB
  • TopicA और TopicC

शर्त वाले एक्सप्रेशन में ज़्यादा से ज़्यादा पांच विषयों को शामिल किया जा सकता है.

किसी शर्त के हिसाब से मैसेज भेजने के लिए:

Node.js

// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
const condition = '\'stock-GOOG\' in topics || \'industry-tech\' in topics';

// See documentation on defining a message payload.
const message = {
  notification: {
    title: '$FooCorp up 1.43% on the day',
    body: '$FooCorp gained 11.80 points to close at 835.67, up 1.43% on the day.'
  },
  condition: condition
};

// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
getMessaging().send(message)
  .then((response) => {
    // Response is a message ID string.
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

Java

// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
String condition = "'stock-GOOG' in topics || 'industry-tech' in topics";

// See documentation on defining a message payload.
Message message = Message.builder()
    .setNotification(Notification.builder()
        .setTitle("$GOOG up 1.43% on the day")
        .setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")
        .build())
    .setCondition(condition)
    .build();

// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
String response = FirebaseMessaging.getInstance().send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);

Python

# Define a condition which will send to devices which are subscribed
# to either the Google stock or the tech industry topics.
condition = "'stock-GOOG' in topics || 'industry-tech' in topics"

# See documentation on defining a message payload.
message = messaging.Message(
    notification=messaging.Notification(
        title='$GOOG up 1.43% on the day',
        body='$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
    ),
    condition=condition,
)

# Send a message to devices subscribed to the combination of topics
# specified by the provided condition.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)

शुरू करें

// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
condition := "'stock-GOOG' in topics || 'industry-tech' in topics"

// See documentation on defining a message payload.
message := &messaging.Message{
	Data: map[string]string{
		"score": "850",
		"time":  "2:45",
	},
	Condition: condition,
}

// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
response, err := client.Send(ctx, message)
if err != nil {
	log.Fatalln(err)
}
// Response is a message ID string.
fmt.Println("Successfully sent message:", response)

C#

// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
var condition = "'stock-GOOG' in topics || 'industry-tech' in topics";

// See documentation on defining a message payload.
var message = new Message()
{
    Notification = new Notification()
    {
        Title = "$GOOG up 1.43% on the day",
        Body = "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.",
    },
    Condition = condition,
};

// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
string response = await FirebaseMessaging.DefaultInstance.SendAsync(message);
// Response is a message ID string.
Console.WriteLine("Successfully sent message: " + response);

REST

POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA
{
   "message":{
    "condition": "'dogs' in topics || 'cats' in topics",
    "notification" : {
      "body" : "This is a Firebase Cloud Messaging Topic Message!",
      "title" : "FCM Message",
    }
  }
}

cURL कमांड:

curl -X POST -H "Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA" -H "Content-Type: application/json" -d '{
  "notification": {
    "title": "FCM Message",
    "body": "This is a Firebase Cloud Messaging Topic Message!",
  },
  "condition": "'dogs' in topics || 'cats' in topics"
}' https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

अगले चरण

  • अपने सर्वर का इस्तेमाल करके, क्लाइंट ऐप्लिकेशन के इंस्टेंस को विषयों की सदस्यता लेने के लिए किया जा सकता है. साथ ही, अन्य मैनेजमेंट टास्क भी किए जा सकते हैं. सर्वर पर विषय की सदस्यताएं मैनेज करना लेख पढ़ें.