Skip to content

Commit

Permalink
Updated documentation for #66
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Aug 1, 2017
1 parent e586db4 commit 5b081f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion docs/GettingStarted.md
Expand Up @@ -56,7 +56,7 @@ public async Task<bool> MakePurchase()
```

## Disposing of In-App Billing Plugin
This plugin also implements IDisposable on all implementations. This ensure that all events are unregistered from the platform. This include unregistering from the SKPaymentQueue on iOS. Only dispose when you need to and are no longer listening to events. The next time you gain access to the `CrossInAppBilling.Current` a new instance will be created.
This plugin also implements IDisposable on all implementations. This ensure that all events are unregistered from the platform. This include unregistering from the SKPaymentQueue on iOS. Only dispose when you need to and are no longer listening to events and you must call `Dispose` on the actual static class. The next time you gain access to the `CrossInAppBilling.Current` a new instance will be created.

```csharp
public async Task<bool> MakePurchase()
Expand All @@ -80,6 +80,35 @@ public async Task<bool> MakePurchase()
await billing.DisconnectAsync();
}
}
CrossInAppBilling.Dispose();
}
```

It is recommended to not us a using statement, but instead just call the single `Dispose` on the static class, which will also dispose the `Current`:

```csharp
public async Task<bool> MakePurchase()
{
if(!CrossInAppBilling.IsSupported)
return false;

var billing = CrossInAppBilling.Current;

try
{
var connected = await billing.ConnectAsync();
if(!connected)
return false;

//make additional billing calls
}
finally
{
await billing.DisconnectAsync();
}
//This does all the disposing you need
CrossInAppBilling.Dispose();
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.InAppBilling.iOS/InAppBillingImplementation.cs
Expand Up @@ -90,7 +90,7 @@ public async override Task<IEnumerable<InAppBillingPurchase>> GetPurchasesAsync(
var purchases = await RestoreAsync();

if (purchases == null)
return;
return null;

var converted = purchases
.Where(p => p != null)
Expand Down

0 comments on commit 5b081f8

Please sign in to comment.