內購消費

Soomla

Soomla是專為獨立遊戲開發者所設計的一套開源且兼容各平台的框架,支援的服務包含排行榜(LevelUp)、購買行為(Store)、社交帳號登入(Profile)以及統整上述功能並附帶分析的整合性服務(Highway)。

準備階段

  • iTunesConnect中Users and Roles的Sandbox Users分頁新增測試用帳號。
  • 新增App並且在In-App Purchase分頁中加入要讓使用者購買的物件後提交審核。
    • Consumable:可以購買多次,如:遊戲幣。
    • Non-consumable:只能購買一次,如:去廣告、額外關卡。
  • 等到商品的status變成approved的狀態就可以用Sandbox Account測試IAP購買了。(Unity Build時記得標示為Development Build)

開發階段

1) 至soomla github下載soomla-unity3d-core與unity3d-store並導入Unity Project。

2) 至Window -> Soomla -> Edit Settings修改Soomla Secret值。

3) 將CoreEvens以及StoreEvents的Prefab拖曳至Hierarchy。

4) 制定虛擬商品(Virtual Goods)以及消費事件(Store Event)。

5) 初始化SoomlaStore的腳本。

public class IAP : MonoBehaviour {

    private static IAP instance = null;

    void Awake () {
        // make sure only initialize one instance
        if(instance == null){
            instance = this;
            GameObject.DontDestroyOnLoad(this.gameObject);
        }
        // destroy unused instance
        else {
            GameObject.Destroy(this);
        }
    }

    void Start () {
        // init soomla events
        new EventsHandler();
        // init soomla store
        SoomlaStore.Initialize(new GoodsHandler());
    }
}

6) 根據消費流程呼叫對應的購買方法。(StoreInventory Functions)

7) 定時更新剩餘商品數量或貨幣數量以及(如果有用到的話)記得放置還原Non-Consumable Item的按鈕。

SoomlaStore.RefreshInventory();
SoomlaStore.RestoreTransactions();

部署階段

  • 憑證簽署部分

    • 註冊Certificate,點選Production區塊的App Store and Ad Hoc項目建立,導入從Keychain匯出的.certSigningRequest檔案後即可。
    • 註冊App Bundle ID,在App Services上記得要勾選In-App Purchase。
    • 產生Provision Profile,點選Distribution區塊的App Store項目,選擇上一步建立的App ID,再選擇Certificate即可下載,下載後連點兩下匯入Xcode完成準備。
  • Xcode

    • 如果在編譯時有出現Lost ISoomlaStore Library的情況,可透過手動指定路徑的方式解決。
      1. Build Settings
      2. Library Search Paths
      3. Add "~/your-project-path/Assets/Plugins/Soomla/Core/"
    • Product -> Archive
    • Window -> Organizer -> Validate -> Submit

results matching ""

    No results matching ""