Pop-ups and Pre-loaders

IOS Message

To show the message we should create an IOSMessage object.  IOSMessage has 2 constructors:

public static IOSMessage Create(string title, string message)
public static IOSMessage Create(string title, string message, string ok)

We can also subscribe to the OnComplete action, in order to find out if the message is closed by the user.

Example:

IOSMessage msg = IOSMessage.Create("Message Titile", "Message message");
msg.OnComplete += onMessageClose;


private void onMessageClose() {
		Debug.Log("Message was just closed");
		IOSNativePopUpManager.showMessage("Result", "Message Closed");
}

IOSDialog

The IOSDialog object also has 2 constructors:

public static IOSDialog Create(string title, string message)
public static IOSDialog Create(string title, string message, string yes, string no)

With IOSDialog we can find out not only when the dialog was closed, but also the user reply.

Example:

IOSDialog dialog = IOSDialog.Create("Dialog Titile", "Dialog message");
dialog.OnComplete += onDialogClose;

private void onDialogClose(IOSDialogResult result) {

		//parsing result
		switch(result) {
		case IOSDialogResult.YES:
			Debug.Log ("Yes button pressed");
			break;
		case IOSDialogResult.NO:
			Debug.Log ("No button pressed");
			break;

		}

		IOSNativePopUpManager.showMessage("Result", result.ToString() + " button pressed");
}

IOSRateUsPopUp

The rate popup is commonly used to prompt the user to rate your app. If the user presses the "Rate" button he will be redirected to the App Store page of your app. If your app is not yet released, you will see a blank page.

With IOSRateUsPopUp you will be able to find out user reply, but you cannot find out which user rated your app or get the actual rating given.

NOTE: Rewarding users for rating is restricted by App Store rules.

The IOSRateUsPopUp  class has following constructors:

public static IOSRateUsPopUp Create()
public static IOSRateUsPopUp Create(string title, string message)
public static IOSRateUsPopUp Create(string title, string message, string rate, string remind, string declined)

Use Example:

IOSRateUsPopUp rate = IOSRateUsPopUp.Create("Like this game?", "Please rate to support future updates!");
rate.OnComplete += onRatePopUpClose;

private void onRatePopUpClose(IOSDialogResult result) {
		switch(result) {
		case IOSDialogResult.RATED:
			Debug.Log ("Rate button pressed");
			break;
		case IOSDialogResult.REMIND:
			Debug.Log ("Remind button pressed");
			break;
		case IOSDialogResult.DECLINED:
			Debug.Log ("Decline button pressed");
			break;
			
		}

		IOSNativePopUpManager.showMessage("Result", result.ToString() + " button pressed");
}

You also can redirect the user to the App Store page of your app using:

IOSNativeUtility.RedirectToAppStoreRatingPage();

Or close any of the current popups with scripting using:

IOSNativePopUpManager.dismissCurrentAlert ();

Pre-Loader

Native pre-loader can be used pretty simple. Use this code to show the preloader:

IOSNativeUtility.ShowPreloader();

It can be dismissed with single function call.

IOSNativeUtility.HidePreloader();

NOTE: The user input is disabled while the preloader is on the screen.

Troubleshooting

While using popups API you may see following warning message in your app:

SendMessage: object IOSPopUp not found!

First of all, nothing to worry about this is just harmless warning. It basically means, that you haven't set complete listener to the popup, and popup was destroyed before click event was delivered. 

Examples

You can find an example of the described API in PopUpExamples.cs.