Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

vipera-npm-registry / de-apprating-plugin   js

Repository URL to install this package:

Version: 1.2.0 

/ docs / index.md

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.

workflow

Dynamic Engine App Rating Plugin Configuration Parameters

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

How to use

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);
});

Rating Status Values

The available status are:

  • NEVER_ASKED
  • OK
  • DECLINED
  • SENT

Rating Type Values

  • POSITIVE
  • NEGATIVE
  • UNKNOWN

Custom UI implementation

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.

In case of User Happy

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);
});

In case of User Unhappy

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);
});

Reset internal status

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);
});

Custom String Resources and Internationalization

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.

Translations values array

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);
});

Javascript API

clobber: DynamicEngine.plugins.AppRating

API Samples

Initialize rating plugin
DynamicEngine.plugins.AppRating.initialize("MyBank", "MyApp", "1.2.3", function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Check feedback status
DynamicEngine.plugins.AppRating.canRequireFeedback(function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Set session information
DynamicEngine.plugins.AppRating.setSessionInfo("Enrico", "mysid_enr", function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Get the feedback status
DynamicEngine.plugins.AppRating.getFeedbackStatus(function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Update feedback status
DynamicEngine.plugins.AppRating.updateFeedbackStatus("SENT",function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Send negative feedback to motif (msg + rating)
DynamicEngine.plugins.AppRating.sendFeedbackWithMessage("message",3,function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Decline rating request
DynamicEngine.plugins.AppRating.declineRequest("POSITIVE",function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Check store review support
DynamicEngine.plugins.AppRating.isStoreReviewSupported(function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Rate app in store
DynamicEngine.plugins.AppRating.rateInStore({ inAppReview:true },function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Get the api model
DynamicEngine.plugins.AppRating.getApiModel(function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Start rating process (with native UI )
DynamicEngine.plugins.AppRating.startRating(function(success) {
  console.log("Success: ", success);
}, function(error) {
  console.error("Error: ", error);
});
Translations setup (for native ui)
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);
});

Native UI

Android

Rating request

Negative rating

Positive rating

iOS

Rating request

Positive rating

PosIn-App Store rating

Negative rating

API Reference

Here you can find the API Reference.

Loading ...