Firebase Cloud Messaging Firebase Cloud Messaging HTTP v1 API की मदद से, iOS डिवाइसों पर लाइव गतिविधि की सूचनाएं, दूर से भेजी, अपडेट की, और खत्म की जा सकती हैं. ध्यान दें कि लाइव गतिविधि की सूचनाएं पाने के लिए, आपके पास iOS 16.1 होना चाहिए. वहीं, दूर से लाइव गतिविधि की सूचनाएं भेजने के लिए, आपके पास iOS 17.2 होना चाहिए.
शुरू करने से पहले
Firebase Cloud Messaging पर लाइव गतिविधि की सुविधा का इस्तेमाल करने से पहले, Apple प्लैटफ़ॉर्म पर Firebase Cloud Messaging क्लाइंट ऐप्लिकेशन सेट अप करें में दिए गए निर्देशों का पालन करें. इससे, क्लाइंट ऐप्लिकेशन में Firebase Cloud Messaging को जोड़ा जा सकेगा.
लाइव गतिविधि शुरू करना
Firebase Cloud Messaging का इस्तेमाल करके, दूर से लाइव गतिविधि शुरू करने के लिए, आपको Apple से पुश-टू-स्टार्ट टोकन लेना होगा. आपको टारगेट ऐप्लिकेशन के लिए, FCM रजिस्ट्रेशन टोकन की भी ज़रूरत होगी.
लाइव गतिविधि शुरू करने के लिए, पेलोड बनाने के लिए, यहां दिए गए कोड के नमूने में मौजूद
apns.payload फ़ील्ड भरें. इससे,
FCM का इस्तेमाल करके, दूर से लाइव गतिविधि शुरू की जा सकेगी.
REST
{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TO_START_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "event": "start", "content-state": { "demo": 1 }, "attributes-type": "DemoAttributes", "attributes": { "demoAttribute": 1 }, "alert": { "title": "test title", "body": "test body" } } } } } }
cURL
curl -X POST -H "Authorization: Bearer OAUTH2_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TO_START_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "event": "start", "content-state": { "demo": 1 }, "attributes-type": "DemoAttributes", "attributes": { "demoAttribute": 1 }, "alert": { "title": "test title", "body": "test body" } } } } } }' https://fcm.googleapis.com/v1/projects/YOUR_PROJECT_ID/messages:send
नमूने को API Explorer में आज़माने के लिए, चलाएं पर क्लिक करें.
लाइव गतिविधि अपडेट करना
Firebase Cloud Messaging का इस्तेमाल करके, दूर से लाइव गतिविधि अपडेट करने के लिए, आपको Apple से पुश टोकन लेना होगा. आपको टारगेट ऐप्लिकेशन के लिए, FCM रजिस्ट्रेशन टोकन की भी ज़रूरत होगी.
लाइव गतिविधि अपडेट करने के लिए, पेलोड बनाने के लिए, यहां दिए गए कोड के नमूने में मौजूद
apns.payload फ़ील्ड भरें. इससे,
FCM का इस्तेमाल करके, दूर से लाइव गतिविधि अपडेट की जा सकेगी.
REST
{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "event": "update", "content-state": { "test1": 100, "test2": "demo" }, "alert": { "title": "test title", "body": "test body" } } } } } }
cURL
curl -X POST -H "Authorization: Bearer OAUTH2_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "event": "update", "content-state": { "test1": 100, "test2": "demo" }, "alert": { "title": "test title", "body": "test body" } } } } } }' https://fcm.googleapis.com/v1/projects/YOUR_PROJECT_ID/messages:send
नमूने को API Explorer में आज़माने के लिए, चलाएं पर क्लिक करें.
लाइव गतिविधि खत्म करना
Firebase Cloud Messaging का इस्तेमाल करके, लाइव गतिविधि खत्म करने के लिए, आपको Apple से पुश टोकन लेना होगा. आपको टारगेट ऐप्लिकेशन के लिए, FCM रजिस्ट्रेशन टोकन की भी ज़रूरत होगी.
लाइव गतिविधि खत्म करने के लिए, पेलोड बनाने के लिए,
यहां दिए गए कोड के नमूने में मौजूद
apns.payload फ़ील्ड भरें.
इससे, FCMका इस्तेमाल करके, दूर से लाइव गतिविधि खत्म की जा सकेगी.
REST
{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "dismissal-date": DISMISSAL_DATE, "event": "end", "content-state": { "test1": 100, "test2": "demo" }, "alert": { "title": "test title", "body": "test body" } } } } } }
cURL
curl -X POST -H "Authorization: Bearer OAUTH2_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "message": { "token": "FCM_TOKEN", "apns": { "live_activity_token": "LIVE_ACTIVITY_PUSH_TOKEN", "headers": { "apns-priority": "10" }, "payload": { "aps": { "timestamp": TIMESTAMP, "dismissal-date": DISMISSAL_DATE, "event": "end", "content-state": { "test1": 100, "test2": "demo" }, "alert": { "title": "test title", "body": "test body" } } } } } }' https://fcm.googleapis.com/v1/projects/YOUR_PROJECT_ID/messages:send
नमूने को API Explorer में आज़माने के लिए, चलाएं पर क्लिक करें.