Constructs object to handle communication with FCM server via Google Play
services.
Public Methods
public Task<CloudMessage>getProxiedNotificationData()
Gets data for a notification that was proxied, if it exists.
Returns
A Task with the
message data of the proxied notification, a Task with a null
CloudMessage if there is no proxied notification data available, or a
failed Task if the data could not be retrieved.
Google Play services will make an HTTP request to the FCM server, passing all string
data in the bundle, along with some device and app data to identify and authenticate
the app instance making the request.
Parameters
data
The request data
Returns
A Task with the response to the request or failed Task with an Exception if there
was a failure in sending the request to Google Play services
public Task<Void>setRetainProxiedNotifications(boolean retain)
Sets whether Google Play services should retain data for notifications that are
proxied so that the app can retrieve the data later.
Parameters
retain
Whether to retain the data or not.
Returns
A Task that
indicates whether the request was successful.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eRpc\u003c/code\u003e class facilitates communication with the FCM server through Google Play services, but direct use of the play-services-cloud-messaging SDK is discouraged in favor of the Firebase Cloud Messaging SDK.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to send requests to Google Play services, handle message acknowledgments, and manage proxied notification data.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003eRpc\u003c/code\u003e to send data bundles to the FCM server, which are then relayed as HTTP requests along with device and app identification.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRpc\u003c/code\u003e allows retrieval of data from proxied notifications and offers control over whether Google Play services retains this data for later access.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003eRpc\u003c/code\u003e handles the underlying communication, developers should prioritize using the Firebase Cloud Messaging SDK for a more streamlined and supported experience.\u003c/p\u003e\n"]]],[],null,["# Rpc\n\npublic class **Rpc** extends [Object](//developer.android.com/reference/java/lang/Object.html) \n| Direct use of play-services-cloud-messaging SDK is not supported. You should use the [Firebase Cloud Messaging SDK](//firebase.google.com/docs/reference/android/com/google/firebase/messaging/package-summary) for communicating with the FCM server.\n\nHandles the communication with FCM server via Google Play services. \n\n### Public Constructor Summary\n\n|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Rpc](/android/reference/com/google/android/gms/cloudmessaging/Rpc#Rpc(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Constructs object to handle communication with FCM server via Google Play services. |\n\n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Task\\\u003c[CloudMessage](/android/reference/com/google/android/gms/cloudmessaging/CloudMessage)\\\u003e | [getProxiedNotificationData](/android/reference/com/google/android/gms/cloudmessaging/Rpc#getProxiedNotificationData())() Gets data for a notification that was proxied, if it exists. |\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [messageHandled](/android/reference/com/google/android/gms/cloudmessaging/Rpc#messageHandled(com.google.android.gms.cloudmessaging.CloudMessage))([CloudMessage](/android/reference/com/google/android/gms/cloudmessaging/CloudMessage) message) Tells Google Play services that a message was handled. |\n| Task\\\u003c[Bundle](//developer.android.com/reference/android/os/Bundle.html)\\\u003e | [send](/android/reference/com/google/android/gms/cloudmessaging/Rpc#send(android.os.Bundle))([Bundle](//developer.android.com/reference/android/os/Bundle.html) data) Send a request to Google Play services. |\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [setRetainProxiedNotifications](/android/reference/com/google/android/gms/cloudmessaging/Rpc#setRetainProxiedNotifications(boolean))(boolean retain) Sets whether Google Play services should retain data for notifications that are proxied so that the app can retrieve the data later. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **Rpc** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nConstructs object to handle communication with FCM server via Google Play\nservices.\n\nPublic Methods\n--------------\n\n#### public Task\\\u003c[CloudMessage](/android/reference/com/google/android/gms/cloudmessaging/CloudMessage)\\\u003e\n**getProxiedNotificationData** ()\n\nGets data for a notification that was proxied, if it exists. \n\n##### Returns\n\n- A [Task](/android/reference/com/google/android/gms/tasks/Task) with the message data of the proxied notification, a Task with a null `CloudMessage` if there is no proxied notification data available, or a failed Task if the data could not be retrieved. \n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **messageHandled** ([CloudMessage](/android/reference/com/google/android/gms/cloudmessaging/CloudMessage) message)\n\nTells Google Play services that a message was handled. \n\n##### Parameters\n\n| message | The message that was successfully handled. |\n|---------|--------------------------------------------|\n\n##### Returns\n\n- A [Task](/android/reference/com/google/android/gms/tasks/Task) that indicates whether the request was successful. \n\n#### public Task\\\u003c[Bundle](//developer.android.com/reference/android/os/Bundle.html)\\\u003e\n**send** ([Bundle](//developer.android.com/reference/android/os/Bundle.html) data)\n\nSend a request to Google Play services.\n\nGoogle Play services will make an HTTP request to the FCM server, passing all string\ndata in the bundle, along with some device and app data to identify and authenticate\nthe app instance making the request. \n\n##### Parameters\n\n| data | The request data |\n|------|------------------|\n\n##### Returns\n\n- A Task with the response to the request or failed Task with an Exception if there was a failure in sending the request to Google Play services \n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **setRetainProxiedNotifications** (boolean retain)\n\nSets whether Google Play services should retain data for notifications that are\nproxied so that the app can retrieve the data later. \n\n##### Parameters\n\n| retain | Whether to retain the data or not. |\n|--------|------------------------------------|\n\n##### Returns\n\n- A [Task](/android/reference/com/google/android/gms/tasks/Task) that indicates whether the request was successful."]]