Implement rate function in Unity for iOS app

Implement rate function in Unity for iOS app

  • Method 1: call Application.OpenURL() with C#
#if UNITY_IPHONE || UNITY_EDITOR
const string APP_ID = [you app id];
var url = string.Format("itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id={0}", APP_ID);
Application.OpenURL(url);
#endif
1
2
3
4
5
  • Method 2: call openURL with Objective-C
NSString *itunesurl = @"itms-apps://itunes.apple.com/cn/app/id[XXXXXX]?mt=8&action=write-review";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:itunesurl]];
1
2

The above two method will direct your app to AppleStore or web browser. That means the user need to switch app and leave your app when do rating.

  • Method 3: use SKStoreProductViewController
UIViewController* unityViewCtrl = UnityGetGLViewController();
SKStoreProductViewController *viewCtrl = [[SKStoreProductViewController alloc] init];   
NSDictionary *parameters = @{SKStoreProductParameterITunesItemIdentifier: [NSNumber numberWithInteger:appId]};
[viewCtrl loadProductWithParameters:parameters completionBlock:nil];    
[unityViewCtrl presentViewController:viewCtrl animated:YES completion:nil];
1
2
3
4
5

This method will pop up a native dialog in your app. The user do not need to leave your app. It seems much better.

评论