facebook twitter hatena line email

「Unity/Csharp/アプリ評価」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
行2: 行2:
 
ReviewPlugin.mmのInspectorを開きiOS/StoreKitにチェックを入れる
 
ReviewPlugin.mmのInspectorを開きiOS/StoreKitにチェックを入れる
  
使用方法
+
アプリを評価使用方法
  Review review = new Review();
+
  AppPage appPage = new AppPage();
  review.Open();
+
appPage.Review();
 +
 
 +
アプリをページ遷移使用方法
 +
AppPage appPage = new AppPage();
 +
  appPage.Open();
  
 
Assets/Plugins/iOS/ReviewPlugin.mm
 
Assets/Plugins/iOS/ReviewPlugin.mm
行16: 行20:
 
</pre>
 
</pre>
  
review.cs
+
AppPage.cs
 
<pre>
 
<pre>
 
using System.Collections;
 
using System.Collections;
行28: 行32:
 
#endif
 
#endif
  
public class Review {
+
public class AppPage {
 
#if UNITY_IOS
 
#if UNITY_IOS
 
[DllImport ("__Internal")]
 
[DllImport ("__Internal")]
 
private static extern float RequestReview();
 
private static extern float RequestReview();
 
#endif
 
#endif
 +
string appleId = "1357901xxx";
 
public void Open () {
 
public void Open () {
string appleId = "1357901xxx";
+
#if UNITY_ANDROID
 +
string url = "market://details?id=" + Application.identifier;
 +
Application.OpenURL(url);
 +
#elif UNITY_IOS
 +
string url = "itms-apps://itunes.apple.com/jp/app/id" + appleId + "?mt=8";
 +
Application.OpenURL(url);
 +
#endif
 +
}
 +
public void Review () {
 
#if UNITY_ANDROID
 
#if UNITY_ANDROID
 
string url = "market://details?id=" + Application.identifier;
 
string url = "market://details?id=" + Application.identifier;

2018年3月31日 (土) 20:03時点における版

サンプル

ReviewPlugin.mmのInspectorを開きiOS/StoreKitにチェックを入れる

アプリを評価使用方法

AppPage appPage = new AppPage();
appPage.Review();

アプリをページ遷移使用方法

AppPage appPage = new AppPage();
appPage.Open();

Assets/Plugins/iOS/ReviewPlugin.mm

#import <StoreKit/StoreKit.h>
extern "C" {
        void RequestReview(){
                [SKStoreReviewController requestReview];
        }
}

AppPage.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

#if UNITY_IOS
using System;
using UnityEngine.iOS;
using System.Runtime.InteropServices;
#endif

public class AppPage {
	#if UNITY_IOS
	[DllImport ("__Internal")]
	private static extern float RequestReview();
	#endif
	string appleId = "1357901xxx";
	public void Open () {
		#if UNITY_ANDROID
		string url = "market://details?id=" + Application.identifier;
		Application.OpenURL(url);
		#elif UNITY_IOS
		string url = "itms-apps://itunes.apple.com/jp/app/id" + appleId + "?mt=8";
		Application.OpenURL(url);
		#endif
	}
	public void Review () {
		#if UNITY_ANDROID
		string url = "market://details?id=" + Application.identifier;
		Application.OpenURL(url);
		#elif UNITY_IOS
		Version iosVersion = new Version(Device.systemVersion);
		Version minVersion = new Version("10.3");
		if (iosVersion >= minVersion) {
			RequestReview();
		} else {
			string url = "itms-apps://itunes.apple.com/jp/app/id" + appleId + "?mt=8&action=write-review";
			Application.OpenURL(url);
		}
		#endif
	}
}

参考

http://kan-kikuchi.hatenablog.com/entry/RequestReview

http://yayaolab.com/archives/355

http://indie-du.com/entry/2017/09/23/173226