MOTIF App Rating Plugin is a client Cordova Plugin for iOS and Android. It's a part of MOTIF frontend platform (Dynamic Engine) and it allows you to implements the AppRating and Feeback feature into your application and communicate with the MOTIF App Feedback Service implementation.
You can use this library to build an hybrid application with Cordova that supports the App Feedback protocol.
This Plugin implements a built-in UI solution or you can create your own using the Plugin API to communicates with MOTIF.
Here the list of the available configuration attributes fot the Splash Screen Plugin:
Name | Default | Platform | Mandatory | Description |
---|---|---|---|---|
appRating.motif.domain | default |
Android/iOS | No | The default Motif Domain name for the Rating Service |
appRating.motif.app | vipera |
Android/iOS | No | The default Motif App name for the Rating Service |
appRating.motif.service | feedback |
Android/iOS | No | The default Motif Service name for the Rating Service |
appRating.motif.operation | appRating |
Android/iOS | No | The default Motif operation name for the Rating Service |
The first thing to do is to initialize this plugin when your app starts with the initialize method. This methods accepts three parameters: the App Domain, the App Name (the MOTIF service catalog values) and the current assets version:
DynamicEngine.plugins.AppRating.initialize("MyBank", "MyApp", "1.2.3", function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
This is used to send to MOTIF some informations regarding the app when the user send a feedback or a ratign value.
After the login in your application you need to set ths current session informations with sessionId and the current userName. This information is necessary to recognize the user during the rating evaluation.
DynamicEngine.plugins.AppRating.setSessionInfo("currentUsername", "currentSID", function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
Now you can require the feeedback in any moment you want in your application simply calling the built-in interface with:
DynamicEngine.plugins.AppRating.startRating(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
Automatically the plugin checks if the feedback can still be required or if it has been requested other times (in this case does not display anything and returns a success value with the status AlreadyAsked).
The rating is requested only once, but if necessary it is possible to reset the internal status to 'NEVER_ASKED' in order to request it again:
DynamicEngine.plugins.AppRating.updateFeedbackStatus("NEVER_ASKED",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
The available status are:
Ff for some reason the built-in UI does not fit your requirements, you can create your own custom UI and use the plugin API to communicate the rating and feedback values to MOTIF.
To check if is possible to require the feedback you need to check the internal status:
DynamicEngine.plugins.AppRating.getFeedbackStatus(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
or simply check:
DynamicEngine.plugins.AppRating.canRequireFeedback(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
Then, if canRequireFeedback returns true you can show your UI.
Then after the UI implementation you can have two cases: the user is happy or the user is unhappy.
If the user is happy he can leave a rating to the store or decline the request:
DynamicEngine.plugins.AppRating.rateInStore({ inAppReview:true },function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
With the { inAppReview:true } parameter you are saying you want to use the in-app store review if available on the device (iOS only, 10.3 or later).
Or decline request with a positive value:
DynamicEngine.plugins.AppRating.declineRequest("POSITIVE",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
If the user is unhappy he can leave a negative rating with a feedback message or decline request:
DynamicEngine.plugins.AppRating.sendFeedbackWithMessage("message",3,function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
The first param is a string message and the second is a rating value (usually from 0 to 5).
Or decline request with a negative value:
DynamicEngine.plugins.AppRating.declineRequest("NEGATIVE",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
In order to reset internal status you can use the updateFeedbackStatus API in this way:
DynamicEngine.plugins.AppRating.updateFeedbackStatus("NEVER_ASKED",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
The default UI has English as the default language. It is also possible to provide localizations or customizations through resource files or programmatically.
To render a string the Plugin proceeds as follows: check if a value has been defined programmatically for that string, if it is not available look for any localization files otherwise it has the default value and language fallback.
Note: The localization files they depend on individual platform: for example iOS uses Localizable Strings. For more informations check the native DEAppRating SDK documentation.
The setTranslations allows you to change programmatically the default strings for the built-in UI. With this function you can pass an array of values (one or more, or all) like this:
var translations = [ {key:"FirstDialogTitle",value:"Rate this app"}, {key:"FirstDialogMessage",value:"How do you feel about this App?"}, {key:"FirstDialogHappyMsg",value:"Happy"}, {key:"FirstDialogUnhappyMsg",value:"Unhappy"}, {key:"FirstDialogDontAskAgainMsg",value:"Don't ask again"}, {key:"PositiveDialogTitle",value:"Rate this app"}, {key:"PositiveDialogMessage",value:"Do you want to leave a feedback?"}, {key:"PositiveDialogYesRate",value:"Yes, rate this"}, {key:"PositiveDialogNoThanks",value:"No, thanks"}, {key:"NegativeDialogTitle",value:"Do you want to leave a feedback"}, {key:"NegativeDialogMessage",value:"Send a comment and a rating if you want:"}, {key:"NegativeDialogFeedbackPlaceholder",value:"Leave here a comment"}, {key:"NegativeDialogCancelMsg",value:"Cancel"}, {key:"NegativeDialogSendMsg",value:"Submit"} ]; DynamicEngine.plugins.AppRating.setTranslations(translations,function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
clobber: DynamicEngine.plugins.AppRating
DynamicEngine.plugins.AppRating.initialize("MyBank", "MyApp", "1.2.3", function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.canRequireFeedback(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.setSessionInfo("Enrico", "mysid_enr", function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.getFeedbackStatus(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.updateFeedbackStatus("SENT",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.sendFeedbackWithMessage("message",3,function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.declineRequest("POSITIVE",function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.isStoreReviewSupported(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.rateInStore({ inAppReview:true },function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.getApiModel(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
DynamicEngine.plugins.AppRating.startRating(function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
var translations = [ {key:"FirstDialogTitle",value:"Rate this app"}, {key:"FirstDialogMessage",value:"How do you feel about this App?"}, {key:"FirstDialogHappyMsg",value:"Happy"}, {key:"FirstDialogUnhappyMsg",value:"Unhappy"}, {key:"FirstDialogDontAskAgainMsg",value:"Don't ask again"}, {key:"PositiveDialogTitle",value:"Rate this app"}, {key:"PositiveDialogMessage",value:"Do you want to leave a feedback?"}, {key:"PositiveDialogYesRate",value:"Yes, rate this"}, {key:"PositiveDialogNoThanks",value:"No, thanks"}, {key:"NegativeDialogTitle",value:"Do you want to leave a feedback"}, {key:"NegativeDialogMessage",value:"Send a comment and a rating if you want:"}, {key:"NegativeDialogFeedbackPlaceholder",value:"Leave here a comment"}, {key:"NegativeDialogCancelMsg",value:"Cancel"}, {key:"NegativeDialogSendMsg",value:"Submit"} ]; DynamicEngine.plugins.AppRating.setTranslations(translations,function(success) { console.log("Success: ", success); }, function(error) { console.error("Error: ", error); });
Here you can find the API Reference.
Loading ...