GriverMPAppRatingExtension
IAPMiniProgram SDK provides the ability to customize the star ratings model of the mini program, so that the Super App can use its own star ratings model to show the start ratings of the mini programs. Follow this topic to realize this ability by implementing the specific interface of IAPMiniProgram SDK.
Procedures
To customize the star ratings model of the mini program, follow these steps:
Step 1. Implement the GriverMPAppRatingExtension interface
Implement the GriverMPAppRatingExtension interface and write code in the required methods according to your business logic.
Code sample as follows:
class CustomRegionRatingExtensionImpl : GriverMPAppRatingExtension {
fun getAppRating(page: Page): RatingModel? {
val model = RatingModel("5",page.app.appId)
//Called when clicking the star area in the options menu panel.
model.clickListener = RatingModel.OnClickListener {
}
return model
}
}
Step 2: Register the CustomRegionRatingExtensionImpl class
Refer to the following sample code and call the registerExtension interface to register CustomRegionRatingExtensionImpl class after initializing the SDK.
IAPConnect.init(application, initConfig, object : InitCallback() {
fun onSuccess() {
//ยทยทยท
Griver.registerExtension(
GriverExtensionManifest(
XxxExtension::class.java,
CustomRegionRatingExtensionImpl()
)
)
}
})
Structures
GriverMPAppRatingExtension interface
The definition of the GriverMPAppRatingExtension interface is shown in the following codes:
interface GriverMPAppRatingExtension : GriverExtension {
fun getAppRating(page: Page?): RatingModel?
}
Methods
Based on the definition above, this interface provides the following methods:
Method | Description |
Gets the star ratings of the mini program. The SDK needs to call this method to obtain the star ratings of the current mini program. This method returns an object of the RatingModel class. |
getAppRating method
Parameter | Data type | Required | Description |
page | Page | No | The page of the mini program that currently displays the star ratings panel. |
RatingModel class
The definition of the RatingModel class is shown in the following codes:
class RatingModel(var ratingScore: String, var ratingAppId: String) {
var clickListener: RatingModel.OnClickListener? = null
interface OnClickListener {
fun click()
}
}
Parameter | Data type | Required | Description |
ratingScore | String | Yes | The star rating of the mini program. |
ratingAppId | String | Yes | The mini program |
clickListener | RatingModel.OnClickListener | No | The listener for when clicking the star area in the options menu panel. |