| प्लैटफ़ॉर्म चुनें: | iOS+ Android Web Flutter Unity C++ |
इस गाइड में, Android क्लाइंट ऐप्लिकेशन में Firebase Cloud Messaging इस्तेमाल करने का तरीका बताया गया है, ताकि भरोसेमंद तरीके से मैसेज भेजे जा सकें.
FCM क्लाइंट के लिए, Android 7.0 या इसके बाद के वर्शन वाले डिवाइस ज़रूरी हैं. साथ ही, उन डिवाइसों पर Google Play Store ऐप्लिकेशन इंस्टॉल होना चाहिए. इसके अलावा, Android 7.0 पर चलने वाला ऐसा एम्युलेटर भी इस्तेमाल किया जा सकता है जिसमें Google APIs मौजूद हों. ध्यान दें कि Android ऐप्लिकेशन को सिर्फ़ Google Play Store के ज़रिए डिप्लॉय करने की कोई पाबंदी नहीं है.
एसडीके टूल सेट अप करना
अगर आपने पहले से ही A/B टेस्टिंग नहीं बनाई है, तो अपने Androidप्रोजेक्ट में Firebase जोड़ें.
हमारा सुझाव है कि FCM का बेहतर अनुभव पाने के लिए, अपने प्रोजेक्ट में सुविधा चालू करें Google Analytics. Google Analytics के लिए, मैसेज डिलीवरी रिपोर्टिंग के लिए FCM ज़रूरी है.
अपने ऐप्लिकेशन के मेनिफ़ेस्ट में बदलाव करना
अपने ऐप्लिकेशन के मेनिफ़ेस्ट में यह जानकारी जोड़ें:
- ऐसी सेवा जो
FirebaseMessagingServiceको बढ़ाती है. अगर आपको बैकग्राउंड में चल रहे ऐप्लिकेशन पर सूचनाएं पाने के अलावा, मैसेज को मैनेज करना है, तो यह ज़रूरी है. फ़ोरग्राउंड ऐप्लिकेशन में सूचनाएं पाने, डेटा पेलोड पाने वगैरह के लिए, आपको इस सेवा को बढ़ाना होगा. - (ज़रूरी नहीं) ऐप्लिकेशन कॉम्पोनेंट में, डिफ़ॉल्ट सूचना आइकॉन और रंग सेट करने के लिए, मेटाडेटा एलिमेंट. जब आने वाले मैसेज में आइकॉन या रंग साफ़ तौर पर सेट नहीं किया जाता, तब Android इन वैल्यू का इस्तेमाल करता है.
- (ज़रूरी नहीं) Android 8.0 (एपीआई लेवल 26) और इसके बाद के वर्शन में,
सूचना चैनलों की सुविधा उपलब्ध है. हमारा सुझाव है कि सूचना चैनलों का इस्तेमाल किया जाए. FCM बुनियादी सेटिंग के साथ डिफ़ॉल्ट
सूचना चैनल उपलब्ध कराता है. अगर आपको अपना डिफ़ॉल्ट चैनल
बनाना और इस्तेमाल करना है, तो
default_notification_channel_idको अपने सूचना चैनल ऑब्जेक्ट के आईडी पर सेट करें. जैसा कि यहां दिखाया गया है. जब आने वाले मैसेज में सूचना चैनल साफ़ तौर पर सेट नहीं किया जाता, तब FCM इस वैल्यू का इस्तेमाल करेगा. ज़्यादा जानने के लिए, सूचना चैनल मैनेज करना लेख पढ़ें.
<service android:name=".java.MyFirebaseMessagingService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. See README(https://goo.gl/l4GJaQ) for more. --> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" /> <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. See README(https://goo.gl/6BKBk7) for more. --> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent" />
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id" />
Android 13 या इसके बाद के वर्शन पर, रनटाइम में सूचना की अनुमति का अनुरोध करना
Android 13 में, सूचनाएं दिखाने के लिए रनटाइम की नई अनुमति की सुविधा जोड़ी गई है. इसका असर Android 13 या इसके बाद के वर्शन पर चलने वाले उन सभी ऐप्लिकेशन पर पड़ेगा जो FCM सूचनाओं का इस्तेमाल करते हैं.
डिफ़ॉल्ट रूप से, FCM SDK (वर्शन 23.0.6 या इसके बाद का वर्शन) में, मेनिफ़ेस्ट में तय की गई
POST_NOTIFICATIONS
अनुमति शामिल होती है. हालांकि, आपके ऐप्लिकेशन को इस अनुमति के रनटाइम वर्शन का अनुरोध भी करना होगा. इसके लिए, android.permission.POST_NOTIFICATIONS कॉन्स्टैंट का इस्तेमाल करें. जब तक उपयोगकर्ता इस अनुमति को नहीं देता, तब तक आपका ऐप्लिकेशन सूचनाएं नहीं दिखा पाएगा.
रनटाइम की नई अनुमति का अनुरोध करने के लिए:
Kotlin
// Declare the launcher at the top of your Activity/Fragment: private val requestPermissionLauncher = registerForActivityResult( ActivityResultContracts.RequestPermission(), ) { isGranted: Boolean -> if (isGranted) { // FCM SDK (and your app) can post notifications. } else { // TODO: Inform user that that your app will not show notifications. } } private fun askNotificationPermission() { // This is only necessary for API level >= 33 (TIRAMISU) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED ) { // FCM SDK (and your app) can post notifications. } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { // TODO: display an educational UI explaining to the user the features that will be enabled // by them granting the POST_NOTIFICATION permission. This UI should provide the user // "OK" and "No thanks" buttons. If the user selects "OK," directly request the permission. // If the user selects "No thanks," allow the user to continue without notifications. } else { // Directly ask for the permission requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) } } }
Java
// Declare the launcher at the top of your Activity/Fragment: private final ActivityResultLauncher<String> requestPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { if (isGranted) { // FCM SDK (and your app) can post notifications. } else { // TODO: Inform user that that your app will not show notifications. } }); private void askNotificationPermission() { // This is only necessary for API level >= 33 (TIRAMISU) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { // FCM SDK (and your app) can post notifications. } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { // TODO: display an educational UI explaining to the user the features that will be enabled // by them granting the POST_NOTIFICATION permission. This UI should provide the user // "OK" and "No thanks" buttons. If the user selects "OK," directly request the permission. // If the user selects "No thanks," allow the user to continue without notifications. } else { // Directly ask for the permission requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS); } } }
आम तौर पर, आपको ऐसा यूज़र इंटरफ़ेस (यूआई) दिखाना चाहिए जिसमें उपयोगकर्ता को उन सुविधाओं के बारे में बताया जाए जो ऐप्लिकेशन को सूचनाएं पोस्ट करने की अनुमति देने पर चालू हो जाएंगी. इस यूआई में, उपयोगकर्ता को सहमति देने या अनुमति न देने के विकल्प मिलने चाहिए. जैसे, ठीक है और नहीं, धन्यवाद बटन. अगर उपयोगकर्ता ठीक है चुनता है, तो सीधे अनुमति का अनुरोध करें. अगर उपयोगकर्ता नहीं, धन्यवाद चुनता है, तो उसे सूचनाएं न मिलने पर भी ऐप्लिकेशन इस्तेमाल करने की अनुमति दें.
आपके ऐप्लिकेशन को उपयोगकर्ता से POST_NOTIFICATIONS
अनुमति का अनुरोध कब करना चाहिए, इस बारे में ज़्यादा जानकारी के लिए, सूचना की रनटाइम
अनुमति
लेख पढ़ें.
एपीआई लेवल 32 या इससे पहले के लेवल को टारगेट करने वाले Android 12L के लिए, सूचना की अनुमतियां
जब आपका ऐप्लिकेशन पहली बार सूचना चैनल बनाता है, तो Android अपने-आप उपयोगकर्ता से अनुमति मांगता है. हालांकि, यह तब तक होता है, जब तक ऐप्लिकेशन फ़ोरग्राउंड में चल रहा हो. हालांकि, चैनल बनाने और अनुमति के अनुरोधों के समय के बारे में कुछ ज़रूरी चेतावनियां हैं:
- अगर आपका ऐप्लिकेशन, बैकग्राउंड में चलने के दौरान अपना पहला सूचना चैनल बनाता है, तो Android सूचना नहीं दिखाएगा. साथ ही, जब तक आपका ऐप्लिकेशन अगली बार नहीं खोला जाता, तब तक उपयोगकर्ता से सूचना की अनुमति नहीं मांगी जाएगी. FCM SDK, FCM सूचना पाने पर ऐसा करता है. इसका मतलब है कि आपका ऐप्लिकेशन खोले जाने और उपयोगकर्ता की अनुमति स्वीकार करने से पहले मिली सूचनाएं खो जाएंगी.
- हमारा सुझाव है कि अनुमति का अनुरोध करने के लिए, प्लैटफ़ॉर्म के एपीआई का फ़ायदा पाने के लिए, अपने ऐप्लिकेशन को Android 13 या इसके बाद के वर्शन को टारगेट करने के लिए अपडेट करें. अगर ऐसा नहीं किया जा सकता, तो आपके ऐप्लिकेशन को सूचनाएं भेजने से पहले, सूचना चैनल बनाने चाहिए. इससे सूचना की अनुमति का डायलॉग ट्रिगर होगा और यह पक्का किया जा सकेगा कि कोई सूचना न खो जाए. ज़्यादा जानकारी के लिए, सूचना की अनुमति के सबसे सही तरीके देखें.
ज़रूरी नहीं: POST_NOTIFICATIONS अनुमति हटाना
डिफ़ॉल्ट रूप से, FCM SDK में POST_NOTIFICATIONS अनुमति शामिल होती है.
अगर आपका ऐप्लिकेशन, सूचना के तौर पर दिए गए मैसेज का इस्तेमाल नहीं करता है (चाहे FCM सूचनाओं, किसी अन्य एसडीके या सीधे आपके ऐप्लिकेशन से पोस्ट किए गए मैसेज के ज़रिए) और आपको अपने ऐप्लिकेशन में यह अनुमति शामिल नहीं करनी है, तो मेनिफ़ेस्ट मर्जर के
मार्कर
remove का इस्तेमाल करके, इसे हटाया जा सकता है. ध्यान रखें कि इस अनुमति को हटाने से, सिर्फ़ FCM सूचनाएं ही नहीं, बल्कि सभी सूचनाएं नहीं दिखेंगी. अपने ऐप्लिकेशन की मेनिफ़ेस्ट फ़ाइल में यह जानकारी जोड़ें:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" tools:node="remove"/>
Firebase इंस्टॉलेशन आईडी ऐक्सेस करना
आपका ऐप्लिकेशन पहली बार शुरू होने पर, FCM SDK, ऐप्लिकेशन इंस्टेंस को
FCM के साथ रजिस्टर करता है और ऐप्लिकेशन इंस्टेंस के लिए एक आइडेंटिफ़ायर दिखाता है. अगर आपको अलग-अलग ऐप्लिकेशन इंस्टेंस को टारगेट करना है, तो आपको इस आइडेंटिफ़ायर को ऐक्सेस करने के लिए
FirebaseMessagingService को बढ़ाकर और
onRegistered() को ओवरराइड करना होगा.
हमारा सुझाव है कि अपडेट किया गया नया आइडेंटिफ़ायर पाएं, क्योंकि पहली बार शुरू होने के बाद आइडेंटिफ़ायर रोटेट हो सकता है.
Firebase इंस्टॉलेशन आईडी के ज़रिए रजिस्ट्रेशन की सुविधा चालू करना
Firebase इंस्टॉलेशन आईडी (FID) का इस्तेमाल करके, अपने ऐप्लिकेशन इंस्टेंस को FCM के साथ रजिस्टर करने की सुविधा चालू करने के लिए, , अपनीAndroidManifest.xml फ़ाइल में यह मेटाडेटा फ़्लैग जोड़ें:
<meta-data android:name="firebase_messaging_installation_id_enabled" android:value="true" />
onRegistered() कॉलबैक लागू करना
ऐप्लिकेशन इंस्टेंस को, FCM के साथ रजिस्टर होने के बाद
, Firebase इंस्टॉलेशन आईडी (FID) का इस्तेमाल करके टारगेट किया जाता है. रजिस्ट्रेशन के बाद FID पाने के लिए,
onRegistered() कॉलबैक लागू करें.
ऐप्लिकेशन इंस्टेंस के रजिस्टर होने के बाद, FCM SDK
FID में होने वाले बदलावों को अपने-आप मॉनिटर करता है. साथ ही, बदलाव का पता चलने पर कॉलबैक को शुरू करता है.
ऑटो-इनिशियलाइज़ेशन की सुविधा चालू होने पर, FCM SDK
रजिस्ट्रेशन को नया बनाए रखने के लिए, FCM बैकएंड के साथ अपने-आप सिंक हो जाता है. साथ ही, यह पक्का करने के लिए कॉलबैक
को शुरू करता है कि आपके ऐप्लिकेशन सर्वर के पास मौजूदा आइडेंटिफ़ायर हो. FID के खो जाने या
पुराने FIDs से बचने के लिए, जब भी यह कॉलबैक ट्रिगर हो, तब आपको FID को अपने ऐप्लिकेशन सर्वर पर भेजना चाहिए.
Kotlin
/** * There are three scenarios when `onRegistered` is called: * 1) Every time a manual `register()` call finishes successfully * 2) Whenever the FID is changed and the app is re-registered with FCM via the new FID. * 3) Automatically on app startup or routine sync when auto-initialization is enabled. * Under #2, there are three scenarios when the existing FID is changed: * A) App is restored to a new device * B) User uninstalls/reinstalls the app * C) User clears app data */ override fun onRegistered(installationId: String) { Log.d(TAG, "Registered installation ID: $installationId") // Send the Firebase Installation ID to your app server. sendRegistrationToServer(installationId) }
Java
/** * There are three scenarios when `onRegistered` is called: * 1) Every time a manual `register()` call finishes successfully * 2) Whenever the FID is changed and the app is re-registered with FCM via the new FID * 3) Automatically on app startup or routine sync when auto-initialization is enabled. * Under #2, there are three scenarios when the existing FID is changed: * A) App is restored to a new device * B) User uninstalls/reinstalls the app * C) User clears app data */ @Override public void onRegistered(@NonNull String installationId) { Log.d(TAG, "Registered installation ID: " + installationId); // Send the Firebase Installation ID to your app server. sendRegistrationToServer(installationId); }
ऑटो-इनिशियलाइज़ेशन की सुविधा बंद होने पर, मैन्युअल तरीके से रजिस्टर करना
अगर आपको ऑटो-इनिशियलाइज़ेशन की सुविधा बंद करनी है, तो FCM SDK, शुरू होने पर
onRegistered() कॉलबैक
को अपने-आप सिंक या ट्रिगर नहीं करेगा. हमारा सुझाव है कि सूचना की अनुमतियां मिलने के बाद,
ऑटो-इनिशियलाइज़ेशन की सुविधा को फिर से चालू करें. ज़्यादा जानने के लिए,
ऑटो-इनिशियलाइज़ेशन की सुविधा को फिर से चालू करना लेख पढ़ें.
अगर ऑटो-इनिशियलाइज़ेशन की सुविधा बंद रखनी है, तो रजिस्ट्रेशन और
onRegistered() कॉलबैक के ज़रिए FID की डिलीवरी को ट्रिगर करने के लिए, ऐप्लिकेशन शुरू होने पर
FirebaseMessaging.getInstance().register() को कॉल करें. इस कॉल को, अपनी मुख्य
Activity के
onCreate() तरीके में लागू किया जा सकता है.
Kotlin
// Trigger manual registration if auto-initialization is turned off. // Consider calling this every time the app starts to guarantee sync status. FirebaseMessaging.getInstance().register() .addOnCompleteListener(this) { task -> if (!task.isSuccessful()) { // Registration failed. Consider retrying the registration with exponential backoff. Log.w(TAG, "Failed to register with Firebase Cloud Messaging", task.exception) } // Success! The Firebase Installation ID can be used to target messages to this app // instance and will be delivered asynchronously to your `onRegistered()` callback. }
Java
// Trigger manual registration if auto-initialization is turned off. // Consider calling this every time the app starts to guarantee sync status. FirebaseMessaging.getInstance().register() .addOnCompleteListener(task -> { if (!task.isSuccessful()) { // Registration failed. Consider retrying the registration with exponential backoff. Log.w(TAG, "Failed to register with Firebase Cloud Messaging", task.exception) } // Success! The Firebase Installation ID can be used to target messages to this app // instance and will be delivered asynchronously to your `onRegistered()` callback. });
FCM रजिस्ट्रेशन टोकन ऐक्सेस करना (अब इसका इस्तेमाल नहीं किया जा सकेगा)
आपका ऐप्लिकेशन पहली बार शुरू होने पर, FCM SDK, क्लाइंट ऐप्लिकेशन इंस्टेंस के लिए एक रजिस्ट्रेशन
टोकन जनरेट करता है. अगर आपको एक ही ऐप्लिकेशन इंस्टेंस को टारगेट करना है या
डिवाइस ग्रुप बनाने हैं, तो आपको इस टोकन को ऐक्सेस करने के लिए
FirebaseMessagingService को बढ़ाकर और onNewToken को ओवरराइड करना होगा. पहली बार शुरू होने के बाद, टोकन रोटेट हो सकता है. इसलिए, हमारा सुझाव है कि अपडेट किया गया नया रजिस्ट्रेशन
टोकन पाएं.
रजिस्ट्रेशन टोकन में इन स्थितियों में बदलाव हो सकता है:
- ऐप्लिकेशन को नए डिवाइस पर रीस्टोर किया गया हो
- उपयोगकर्ता ने ऐप्लिकेशन को अनइंस्टॉल/फिर से इंस्टॉल किया हो
- उपयोगकर्ता ने ऐप्लिकेशन का डेटा मिटाया हो.
मौजूदा रजिस्ट्रेशन टोकन पाना
मौजूदा टोकन पाने के लिए,
FirebaseMessaging.getInstance().getToken() को कॉल करें:
Kotlin
FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task -> if (!task.isSuccessful) { Log.w(TAG, "Fetching FCM registration token failed", task.exception) return@OnCompleteListener } // Get new FCM registration token val token = task.result // Log and toast val msg = getString(R.string.msg_token_fmt, token) Log.d(TAG, msg) Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() })
Java
FirebaseMessaging.getInstance().getToken() .addOnCompleteListener(new OnCompleteListener<String>() { @Override public void onComplete(@NonNull Task<String> task) { if (!task.isSuccessful()) { Log.w(TAG, "Fetching FCM registration token failed", task.getException()); return; } // Get new FCM registration token String token = task.getResult(); // Log and toast String msg = getString(R.string.msg_token_fmt, token); Log.d(TAG, msg); Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show(); } });
टोकन जनरेट होने की प्रोसेस को मॉनिटर करना
onNewToken कॉलबैक, नया टोकन जनरेट होने पर शुरू होता है.
Kotlin
/** * Called if the FCM registration token is updated. This may occur if the security of * the previous token had been compromised. Note that this is called when the * FCM registration token is initially generated so this is where you would retrieve the token. */ override fun onNewToken(token: String) { Log.d(TAG, "Refreshed token: $token") // If you want to send messages to this application instance or // manage this apps subscriptions on the server side, send the // FCM registration token to your app server. sendRegistrationToServer(token) }
Java
/** * There are two scenarios when onNewToken is called: * 1) When a new token is generated on initial app startup * 2) Whenever an existing token is changed * Under #2, there are three scenarios when the existing token is changed: * A) App is restored to a new device * B) User uninstalls/reinstalls the app * C) User clears app data */ @Override public void onNewToken(@NonNull String token) { Log.d(TAG, "Refreshed token: " + token); // If you want to send messages to this application instance or // manage this apps subscriptions on the server side, send the // FCM registration token to your app server. sendRegistrationToServer(token); }
टोकन पाने के बाद, इसे अपने ऐप्लिकेशन सर्वर पर भेजा जा सकता है और अपनी पसंद के तरीके से सेव किया जा सकता है.
Google Play services की जांच करना
Play Services SDK पर निर्भर रहने वाले ऐप्लिकेशन को, Google Play services की सुविधाओं को ऐक्सेस करने से पहले, डिवाइस पर Google Play services के साथ काम करने वाले APK की जांच करनी चाहिए. ज़्यादा जानने के लिए, Google Play
services सेट अप करना लेख पढ़ें. हमारा सुझाव है कि यह जांच दो जगहों पर की जाए: मुख्य गतिविधि के onCreate() तरीके में और उसके onResume() तरीके में. onCreate() में की गई जांच से यह पक्का होता है कि जांच में पास हुए बिना, ऐप्लिकेशन का इस्तेमाल नहीं किया जा सकता. onResume() में की गई जांच से यह पक्का होता है कि अगर उपयोगकर्ता, 'वापस जाएं' बटन जैसे किसी अन्य तरीके से चल रहे ऐप्लिकेशन पर वापस आता है, तो भी जांच की जाती है.
अगर डिवाइस में Google Play services का ऐसा वर्शन नहीं है जो आपके
ऐप्लिकेशन के साथ काम करता है, तो आपका
GoogleApiAvailability.makeGooglePlayServicesAvailable()
को कॉल कर सकता है. इससे उपयोगकर्ताओं को Play Store से Google Play services डाउनलोड करने की अनुमति मिल जाएगी.
ऑटो-इनिशियलाइज़ेशन की सुविधा बंद करना
जब FCM रजिस्ट्रेशन जनरेट होता है, तो लाइब्रेरी,
आइडेंटिफ़ायर और कॉन्फ़िगरेशन डेटा को Firebase पर अपलोड करती है. अगर आपको ऑटो-रजिस्ट्रेशन की सुविधा बंद करनी है, तो Analytics कलेक्शन और FCM ऑटो-इनिशियलाइज़ेशन की सुविधा बंद करें. इसके लिए, आपको अपने AndroidManifest.xml में ये मेटाडेटा वैल्यू जोड़नी होंगी:
<meta-data android:name="firebase_messaging_auto_init_enabled" android:value="false" /> <meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
ऑटो-इनिशियलाइज़ेशन की सुविधा को फिर से चालू करना
FCM ऑटो-इनिशियलाइज़ेशन की सुविधा को फिर से चालू करने के लिए, रनटाइम कॉल करें:
Kotlin
Firebase.messaging.isAutoInitEnabled = true
Java
FirebaseMessaging.getInstance().setAutoInitEnabled(true);
Analytics कलेक्शन की सुविधा को फिर से चालू करने के लिए, setAnalyticsCollectionEnabled()
तरीके को FirebaseAnalytics क्लास का कॉल करें. उदाहरण के लिए:
setAnalyticsCollectionEnabled(true);
एक बार सेट करने के बाद, ऐप्लिकेशन रीस्टार्ट होने पर भी ये वैल्यू बनी रहती हैं.
सूचना वाला मैसेज भेजना
यह पक्का करने के लिए कि आपका Android क्लाइंट सही तरीके से सेट अप किया गया है, यहां दिए गए निर्देशों का इस्तेमाल करके, टेस्ट सूचना वाला मैसेज भेजा जा सकता है:
टारगेट डिवाइस पर ऐप्लिकेशन इंस्टॉल करें और उसे चलाएं.
पक्का करें कि डिवाइस पर ऐप्लिकेशन बैकग्राउंड में चल रहा हो.
Firebase कंसोल में, DevOps और लोगों की दिलचस्पी > मैसेज भेजने की सुविधा पर जाएं
कैंपेन बनाएं.
अगर यह आपका पहला मैसेज है, तो:
अपना पहला कैंपेन बनाएं को चुनें.
Firebase सूचना वाले मैसेज को चुनें और बनाएं को चुनें.
अगर आपने पहले कैंपेन बनाए हैं, तो:
कैंपेन टैब पर, नया कैंपेन को चुनें.
सूचनाएं पर क्लिक करें.
मैसेज का टेक्स्ट डालें. अन्य सभी फ़ील्ड ज़रूरी नहीं हैं.
दाईं ओर मौजूद पैनल में, टेस्ट मैसेज भेजें को चुनें.
FCM रजिस्ट्रेशन टोकन जोड़ें लेबल वाले फ़ील्ड में, इस गाइड के पिछले सेक्शन में मिला रजिस्ट्रेशन टोकन डालें.
टेस्ट को चुनें.
टारगेट किए गए क्लाइंट डिवाइस को सूचना मिलनी चाहिए. इस दौरान, ऐप्लिकेशन बैकग्राउंड में चल रहा होना चाहिए.
अपने ऐप्लिकेशन पर मैसेज डिलीवरी के बारे में जानकारी पाने के लिए, DevOps और लोगों की दिलचस्पी > मैसेज भेजने की सुविधा > रिपोर्ट डैशबोर्ड Firebase कंसोल में जाएं. इस डैशबोर्ड में, Apple और Android डिवाइसों पर भेजे गए और खोले गए मैसेज की संख्या रिकॉर्ड की जाती है. साथ ही, Android ऐप्लिकेशन के लिए "इंप्रेशन" (उपयोगकर्ताओं को दिखने वाली सूचनाएं) का डेटा भी रिकॉर्ड किया जाता है.
अगले चरण
सेटअप के चरण पूरे करने के बाद, Android के लिए FCM का इस्तेमाल करने के कुछ विकल्प यहां दिए गए हैं: