Package io.rong.push

Class RongPushClient

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      RongPushClient()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static void registerGCM(Context context) Registers for GCM push notifications.
      static void registerFCM(Context context) Registers for FCM push notifications.
      static void registerMiPush(Context context, String miAppId, String miAppKey) Registers Xiaomi Push.
      static void registerHWPush(Context context) Registers for Huawei push notifications.
      static void registerMZPush(Context context, String appId, String appKey) Registers for Meizu push notifications.
      static void resolveHWPushError(Activity activity, long errorCode) Note: After upgrading Huawei Push to version 3.0, this interface has been deprecated and calling it has no effect.
      static void resolveHMSCoreUpdate(Activity activity) Handles the logic for upgrading the HMS Core version below 3.0, which cannot obtain the token and triggers a pop-up prompt.
      static void init(Context context, String appKey) Initialization.
      static void init(Context context, String appKey, InitOption initOption, boolean isPushEnable) Initialization (call initialization in the main process of the application).
      static void setPushEventListener(PushEventListener listener) Set the push event listener.
      static PushEventListener getPushEventListener() Retrieves the push event listener set at the application layer.
      static void stopService(Context context) Stops RCpush services.
      static void stopRongPushService(Context context)
      static void redirected(Context context) Push service redirection.
      static void clearAllNotifications(Context context) Clears all notification messages in the notification bar.
      static PushType getCurrentPushType(Context context) Retrieves the currently used push notification type.
      static void clearAllPushNotifications(Context context) Clears all push notifications and background message notifications.
      static void clearAllPushServiceNotifications(Context context) Clears all push notifications from background push services.
      static void clearNotificationById(Context context, int notificationId) Clears the notification bar based on the notification ID.
      static void recordNotificationEvent(String pushId) Records the click event of a push notification when using the backend push feature in the Developer Console.
      static void recordNotificationEvent(PushNotificationMessage pushNotificationMessage, PushType pushType) Uploads the click event of a push notification.
      static void recordHWNotificationEvent(Intent intent) Tracks Huawei push click events.
      static void stopRongPush(Context context) Stops the RCpush notification service.
      static void sendNotification(Context context, PushNotificationMessage notificationMessage) Sends a notification.
      static void sendNotification(Context context, PushNotificationMessage notificationMessage, int left) Sends a notification.
      static void setNotifiationSound(Uri uri) Sets the notification ringtone URI, which must be an absolute path.
      static void checkManifest(Context context) Helper method to verify whether the RCPush service configuration in the AndroidManifest is correct.
      static void cancelPushHeartBeat(Context context)
      static void sendPushPing(Context context)
      static void updatePushContentShowStatus(Context context, boolean isShow)
      static void recordPushArriveEvent(Context context, PushType pushType, PushNotificationMessage pushNotificationMessage) Upload push delivery event The push delivery rate in the developer console is calculated based on this event uploaded by the client.
      static void setPushConfig(PushConfig config) Configures push-related settings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RongPushClient

        RongPushClient()
    • Method Detail

      • registerGCM

        @Deprecated() static void registerGCM(Context context)

        Registers for GCM push notifications. Must be called before init().

        This method is deprecated. Please use setPushConfig instead.

        Parameters:
        context - The context.
      • registerFCM

        @Deprecated() static void registerFCM(Context context)

        Registers for FCM push notifications. Must be called before init().

        This method is deprecated. Please use setPushConfig instead.

      • registerMiPush

        @Deprecated() static void registerMiPush(Context context, String miAppId, String miAppKey)

        Registers Xiaomi Push. Must be called before init().

        This method is deprecated. Please use setPushConfig.

        Parameters:
        context - The context.
        miAppId - The AppId of your application registered on the Xiaomi Developer Platform.
        miAppKey - The AppKey of your application registered on the Xiaomi Developer Platform.
      • registerHWPush

        @Deprecated() static void registerHWPush(Context context)

        Registers for Huawei push notifications. Must be called before init().

        This method is deprecated. Please use setPushConfig instead.

        Parameters:
        context - The context.
      • registerMZPush

        @Deprecated() static void registerMZPush(Context context, String appId, String appKey)

        Registers for Meizu push notifications. Must be called before init().

        This method is deprecated. Please use setPushConfig.

        Parameters:
        context - The context.
        appId - The Meizu appId generated after registering the application on the Meizu backend.
        appKey - The Meizu appKey generated after registering the application on the Meizu backend.
      • resolveHWPushError

        @Deprecated() static void resolveHWPushError(Activity activity, long errorCode)

        Note: After upgrading Huawei Push to version 3.0, this interface has been deprecated and calling it has no effect. Handle Huawei Push connection errors by end-user operations. Only the following error codes can be resolved by end-user operations: * SERVICE_MISSING* com.huawei.hms.api.ConnectionResult#SERVICE_VERSION_UPDATE_REQUIRED* com.huawei.hms.api.ConnectionResult#BINDFAIL_RESOLUTION_REQUIRED *

        Parameters:
        activity - The activity of the current interface, cannot be null
        errorCode - The error code
      • resolveHMSCoreUpdate

         static void resolveHMSCoreUpdate(Activity activity)

        Handles the logic for upgrading the HMS Core version below 3.0, which cannot obtain the token and triggers a pop-up prompt.

        Parameters:
        activity - The current activity of the interface, which cannot be null
      • init

         static void init(Context context, String appKey)

        Initialization.

        Parameters:
        context - The context.
        appKey - The unique key for the app.
      • init

         static void init(Context context, String appKey, InitOption initOption, boolean isPushEnable)

        Initialization (call initialization in the main process of the application). Use this interface when users set their own push server address.

        Parameters:
        context - The context.
        appKey - The unique key of the app.
      • setPushEventListener

         static void setPushEventListener(PushEventListener listener)

        Set the push event listener.

        All third-party push-related events can be intercepted through this listener. RongCloud's default push notifications, which require cross-process communication, still need to be monitored via io.rong.push.notification.PushMessageReceiver.

        Parameters:
        listener - The push event listener
      • getPushEventListener

         static PushEventListener getPushEventListener()

        Retrieves the push event listener set at the application layer.

        Returns:

        The push event listener

      • stopService

         static void stopService(Context context)

        Stops RCpush services. If a third-party push service is in use, the connection to the third-party push service will also be terminated.

        Parameters:
        context - The application context
      • redirected

         static void redirected(Context context)

        Push service redirection. This interface allows re-accessing the push navigation server and establishing a connection based on the returned address.

        Parameters:
        context - Application context
      • clearAllNotifications

         static void clearAllNotifications(Context context)

        Clears all notification messages in the notification bar.

        Parameters:
        context - The context
      • getCurrentPushType

         static PushType getCurrentPushType(Context context)

        Retrieves the currently used push notification type.

        If the configuration fails, the returned push type is UNKNOWN.

      • clearAllPushNotifications

         static void clearAllPushNotifications(Context context)

        Clears all push notifications and background message notifications. For example: If Account A is offline or moved to the background, and Account B sends a message to Account A, Account A's device will receive a notification for this message. Calling this function will clear such notifications. However, push notifications sent via the broadcast push service from the developer backend will remain and will not be cleared.

        Parameters:
        context - The context.
      • clearAllPushServiceNotifications

         static void clearAllPushServiceNotifications(Context context)

        Clears all push notifications from background push services. Background push services refer to broadcast push services from the developer's backend.

        Parameters:
        context - The context.
      • clearNotificationById

         static void clearNotificationById(Context context, int notificationId)

        Clears the notification bar based on the notification ID.

        Parameters:
        context - The context.
        notificationId - The ID of the notification message.
      • recordNotificationEvent

        @Deprecated() static void recordNotificationEvent(String pushId)

        Records the click event of a push notification when using the backend push feature in the Developer Console. The push open rate in the Developer Console is calculated based on this event uploaded by the client. * For versions prior to 2.6.0, please search for the tag push in the knowledge base for related instructions on using the push open rate. * For versions after 2.6.0, if the user is using the SDK's built-in notification implementation, there is no need to call this method to track the push open rate, as the SDK handles the statistics internally. * However, if the user has customized the display of the notification bar for push notifications, this method must be called when the notification is clicked to upload the push open event to the server.

        Parameters:
        pushId - The ID of the push notification.
      • recordNotificationEvent

         static void recordNotificationEvent(PushNotificationMessage pushNotificationMessage, PushType pushType)

        Uploads the click event of a push notification. The open rate of push notifications in the developer backend is calculated based on this event uploaded by the client.

        Parameters:
        pushNotificationMessage - The push notification message
        pushType - The type of push notification
      • recordHWNotificationEvent

         static void recordHWNotificationEvent(Intent intent)

        Tracks Huawei push click events. If the user has not customized the intent in the developer console, this interface needs to be called in the `onCreate` method of the activity configured for the conversation list UI. Example:

        if(intent != null && intent.getData() != null && intent.getData().getScheme() != null
                      && intent.getData().getScheme().equals(rong)
                      && intent.getData().getQueryParameter(isFromPush) != null
                      && intent.getData().getQueryParameter(isFromPush).equals(true)){
                          RongPushClient.recordHWNotificationEvent(intent);
                      }

        If the user has customized the intent for Huawei push clicks in the developer console, the intent needs to be filtered in the configured activity based on the custom intent, and then this interface should be called.

        Parameters:
        intent - The intent passed from the Huawei push click.
      • stopRongPush

        @Deprecated() static void stopRongPush(Context context)

        Stops the RCpush notification service.

        Parameters:
        context - The context.
      • sendNotification

         static void sendNotification(Context context, PushNotificationMessage notificationMessage)

        Sends a notification. If using IMLib for development, when the application is in the background and needs to display a notification, this function can be directly called to show the notification.

        Parameters:
        context - The context.
        notificationMessage - The notification message exposed by RongCloud.
      • sendNotification

         static void sendNotification(Context context, PushNotificationMessage notificationMessage, int left)

        Sends a notification. If developing with IMLib, when the app is in the background and requires a background notification, this function can be directly called to display the notification.

        Parameters:
        context - The context.
        notificationMessage - The notification message exposed by RongCloud.
        left - The count of offline messages.
      • setNotifiationSound

         static void setNotifiationSound(Uri uri)

        Sets the notification ringtone URI, which must be an absolute path. Calling this method after init but before connect ensures that all received messages after connection will use this ringtone.

        Parameters:
        uri - The ringtone URI
      • checkManifest

        @Deprecated() static void checkManifest(Context context)

        Helper method to verify whether the RCPush service configuration in the AndroidManifest is correct.

        Parameters:
        context - The context.
      • recordPushArriveEvent

         static void recordPushArriveEvent(Context context, PushType pushType, PushNotificationMessage pushNotificationMessage)

        Upload push delivery event

        The push delivery rate in the developer console is calculated based on this event uploaded by the client.

        Parameters:
        context - The context
        pushType - The push type PushType
        pushNotificationMessage - The push notification message PushNotificationMessage
      • setPushConfig

         static void setPushConfig(PushConfig config)

        Configures push-related settings. Must be called before initializing the SDK.

        Parameters:
        config - Push configuration.