public void TestRestore AddIapHandlers Purchaser instanse RestoreCompl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public void TestRestore()
{
AddIapHandlers();
Purchaser.instanse.RestoreComplete += RestorationSuccess;
LoaderPanel.instanse.Show();
Purchaser.instanse.RestorePurchases();
}
#region Purchase
public void RemoveAdsButtonTouchedUpInside()
{
AddIapHandlers();
Purchaser.instanse.PurchaseComplete += PurchaseMessageHandler;
LoaderPanel.instanse.Show();
Purchaser.instanse.BuyRemoveAds();
}
private void AddIapHandlers()
{
Purchaser.instanse.PurchaseError += PurchaseMessageHandler;
Purchaser.instanse.PurchaseUserCancelled += PurchaseUserCancelledHandler;
}
private void RemoveIapHandler()
{
Purchaser.instanse.PurchaseComplete -= PurchaseMessageHandler;
Purchaser.instanse.PurchaseError -= PurchaseMessageHandler;
Purchaser.instanse.RestoreComplete -= RestorationSuccess;
Purchaser.instanse.PurchaseUserCancelled -= PurchaseUserCancelledHandler;
}
private void RestorationSuccess()
{
RemoveIapHandler();
LoaderPanel.instanse.DisplayError("Restoration complete");
}
private void PurchaseUserCancelledHandler()
{
RemoveIapHandler();
LoaderPanel.instanse.Hide();
}
private void PurchaseMessageHandler(string errorMessage)
{
RemoveIapHandler();
LoaderPanel.instanse.DisplayError(errorMessage);
}
#endregion