hyphenate_SDK4.0 4.8.0
hyphenate java IM SDK
Public Member Functions | List of all members
com.hyphenate.push.PushListener Class Referenceabstract

Public Member Functions

boolean isSupportPush (EMPushType pushType, EMPushConfig pushConfig)
 
String getPushToken (EMPushType pushType, EMPushConfig pushConfig)
 

Detailed Description

The push settings class for customized push.

Member Function Documentation

◆ getPushToken()

String com.hyphenate.push.PushListener.getPushToken ( EMPushType  pushType,
EMPushConfig  pushConfig 
)

Gets the FCM device token.

Parameters
pushTypeThe push type.
pushConfigThe push configs.
Returns
Returns the device token to register.

◆ isSupportPush()

boolean com.hyphenate.push.PushListener.isSupportPush ( EMPushType  pushType,
EMPushConfig  pushConfig 
)

Determines whether a push type is supported. This function will be called multiple times, each time passing a pushType to the user to return a boolean value based on the pushType provided by the SDK, allowing the SDK to determine whether the client environment supports the push type. For example:

  1. If you want to use FCM push, you need to call EMPushHelper.getInstance().setPushListener() to set the listener and override the isSupportPush function, returning true when the parameter pushType == ChatPushType.FCM.
    EMPushHelper.getInstance().setPushListener(new PushListener() {
    ……
    @Override
    public boolean isSupportPush(EMPushType pushType, EMPushConfig pushConfig) {
    // 由用户实现代码判断设备是否支持FCM推送
    if(pushType == EMPushType.FCM){
    EMLog.d("FCM", "GooglePlayServiceCode:"+GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context));
    return GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS;
    }else if (pushType == EMPushType.HONORPUSH){
    ……
    }
    return super.isSupportPush(pushType, pushConfig);
    }
    });
    boolean isSupportPush(EMPushType pushType, EMPushConfig pushConfig)
    Definition: PushListener.java:82
    Similarly, if you return true for a specific pushType (such as HONORPUSH), the SDK will use that type of push, and the function will not be called again. Note: The final success of registration depends on whether the client environment has integrated the relevant push suite.
  2. If you return false for all pushTypes in the isSupportPush callback function, the final push will be through the Huanxin channel.
  3. If this function is not implemented, the SDK will default to determining which push implementation is supported based on the device model.
Parameters
pushTypeThe push type.
pushConfigThe push configurations.
Returns
Returns whether the push type is supported.

The documentation for this class was generated from the following file: