Using the iOS 10.3 Request Review Dialog

We’ve all used those apps that constantly popup an interface to ask you to review the app with “Not now” or “Remind me later” (or never) options. They’ll usually popup randomly and can all look slightly different. This week, Apple released iOS 10.3, which includes a new, official API for requesting ratings and reviews: SKStoreReviewController. Thanks to our own Hans Knöchel, you can use it now, both as a classic native module AND in Hyperloop!

For the Native Module

Download the stable release as a zip and drop it into the root of your project.

Next, update your tiapp.xml file to include:

<modules>
  <module platform="iphone">ti.reviewdialog</module>
</modules>

Finally, add the following code to your Alloy.js or Index.js file:

var ReviewDialog = require('ti.reviewdialog');
ReviewDialog.requestReview();

For a Hyperloop-Enabled Project

Use the following JavaScript code:

var SKStoreReviewController = require('StoreKit/SKStoreReviewController');
var UIDevice = require('UIKit/UIDevice');
var NSNumericSearch = require('Foundation').NSNumericSearch;
var NSOrderedAscending = require('Foundation').NSOrderedAscending;

function isRequestReviewSupported() {
    return UIDevice.currentDevice.systemVersion.compareOptions('10.3', NSNumericSearch) != NSOrderedAscending;
};

function requestReview() {
    SKStoreReviewController.requestReview();
};

if (isRequestReviewSupported() && !Ti.App.Properties.getBool('reviewDialogRequested', false)) {
   Ti.App.Properties.setBool('reviewDialogRequested', true);
   Review.requestReview();
}

We’ve made it super easy for you to add this in by creating a commonJS Hyperloop module over in our Hyperloop Examples repository. So, be sure to check that out, the demo code AND some other great examples of using Hyperloop in Titanium.

example-screen

Code Strong!

2 COMMENTS

Comments are closed.