Game crashing when attempting to trigger rating

BenPritchardBenPritchard GBMember, University

Hi,

I'm in the process of updating a Monogame-based game I originally released about 18 months ago, then pulled from the app store due to problems around the time everything had to be made 64-bit. In the process of testing, I have found that the code I used to make a "rate game" button cause the rating view to appear has stopped working - the game makes contact with iTunes then crashes.

Here's the code I'm using:

[code]
using System;

using Foundation;
using UIKit;
using StoreKit;

namespace Leda.Core.External_APIS.iOS
{
public class ReviewAppManager
{
private SKStoreProductViewController _storeProductViewController;
private UIViewController _rootViewController;

    public bool Successful { get; private set; }
    public string ErrorMessage { get; private set;}

    public Action CompletionCallback
    {
        set {
            _storeProductViewController.Finished += (sender, err) => {
                _rootViewController.DismissViewController(true, value);
            };
        }
    }

    public ReviewAppManager()
    {
        _storeProductViewController = new SKStoreProductViewController();
    }

    public void InitiateReviewProcess(int appID)
    {
        Successful = false;
        ErrorMessage = "";

        StoreProductParameters spp = new StoreProductParameters(appID);

        if (_rootViewController == null)
        {
            _rootViewController = UIApplication.SharedApplication.Windows[0].RootViewController;
        }

        _storeProductViewController.LoadProduct(spp, (ok, err) => {
            if (ok) {
                _rootViewController.PresentViewController(_storeProductViewController,true,() => {
                    Successful = true;
                });
            } else if (err != null) { 
                ErrorMessage = err.ToString();
            }
        });
    }
}

}
[/code]

When InitiateReviewProcess is called, CompletionCallback is set to the following function:

[code]
private void HandleRatingAttemptComplete()
{
string message = "Thank you!";

        if (!GameBase.Instance.ReviewManager.Successful)
        {
            if (!string.IsNullOrEmpty(GameBase.Instance.ReviewManager.ErrorMessage)) 
            { 
                message = GameBase.Instance.ReviewManager.ErrorMessage;
            }
            else
            {
                message = "Unable to connect to iTunes...";
            }
        }

        _externalActionDialog.CompleteAction(message, GameBase.Instance.ReviewManager.Successful);
    }

[/code]

From what I can tell, the crash point is when I try and have the rootViewController present the storeProductViewController - this is as precise as I can get via breakpoints. I should also point out that the app ID I am using to test is that of another app, as trying to use the app ID for an app that has been pulled from the store (as I had to do) does not even get into the review process.

Can anyone advise? I have also cross-posted to the Monogame forums, but this feels like more of an underlying issue, given that I originally used the documentation here to get started.

Thanks!

Tagged:
Sign In or Register to comment.