InstanceIDListenerService

  • InstanceIDListenerService is a deprecated Android service for handling Instance ID token refresh notifications.

  • Apps using deprecated Instance ID or GCM must extend this service and implement the onTokenRefresh() method.

  • The service needs to be declared in the Android manifest with a specific intent filter and marked as not exported.

  • InstanceIDListenerService inherits methods for various Android system interactions, including managing the service lifecycle, handling configuration, and accessing system services.

public class InstanceIDListenerService extends Service

This class was deprecated.
Instance ID is deprecated and replaced by Firebase Instance ID. See the FCM migration guide for details on how to migrate to Firebase Instance ID.

Base class to handle Instance ID service notifications on token refresh.

Any app using Instance ID or GCM must include a class extending InstanceIDListenerService and implement onTokenRefresh().

Include the following in the manifest:

 <service android:name=".YourInstanceIDListenerService" android:exported="false">
     <intent-filter>
         <action android:name="com.google.android.gms.iid.InstanceID"/>
     </intent-filter>
 </service>

Do not export this service. Instead, keep it private to prevent other apps accessing your service.

Inherited Constant Summary

Public Constructor Summary

Public Method Summary

void
onTokenRefresh()
Called when the system determines that the tokens need to be refreshed.

Inherited Method Summary

Public Constructors

public InstanceIDListenerService ()

Public Methods

public void onTokenRefresh ()

Called when the system determines that the tokens need to be refreshed. The application should call getToken() and send the tokens to all application servers.

This will not be called very frequently, it is needed for key rotation and to handle special cases.

The system will throttle the refresh event across all devices to avoid overloading application servers with token updates.