-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from thisisthekap/br_2_add_ios_extensions
added ios extensions
- Loading branch information
Showing
14 changed files
with
367 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
Xamarin.RevenueCat.iOS.Extensions/Exceptions/PurchasesErrorException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using Foundation; | ||
using Purchases; | ||
|
||
namespace Xamarin.RevenueCat.iOS.Extensions.Exceptions | ||
{ | ||
public class PurchasesErrorException : Exception | ||
{ | ||
public NSError PurchasesError { get; } | ||
public bool UserCancelled { get; } | ||
|
||
public NSObject ReadableErrorCode { get; } | ||
public NSObject UnderlyingError { get; } | ||
public string LocalizedDescription { get; } | ||
public RCPurchasesErrorCode PurchasesErrorCode { get; } | ||
|
||
public PurchasesErrorException(NSError purchasesError, bool userCancelled) | ||
: base($"{purchasesError?.Description} userCancelled: {userCancelled}") | ||
{ | ||
PurchasesError = purchasesError; | ||
UserCancelled = userCancelled; | ||
if (purchasesError != null) | ||
{ | ||
purchasesError.UserInfo.TryGetValue(RCPurchasesErrors.RCReadableErrorCodeKey, | ||
out NSObject readableErrorCode); | ||
ReadableErrorCode = readableErrorCode; | ||
purchasesError.UserInfo.TryGetValue(NSError.UnderlyingErrorKey, out NSObject underlyingError); | ||
UnderlyingError = underlyingError; | ||
var localizedDescription = purchasesError.LocalizedDescription; | ||
LocalizedDescription = localizedDescription; | ||
|
||
int purchaseErrorCodeInt = (int) purchasesError.Code; | ||
PurchasesErrorCode = (RCPurchasesErrorCode) purchaseErrorCodeInt; | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Xamarin.RevenueCat.iOS.Extensions/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Xamarin.RevenueCat.iOS.Extensions")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Xamarin.RevenueCat.iOS.Extensions")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("50c7b8c9-e664-45af-b88e-0c9b8b9c1be1")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Purchases; | ||
using StoreKit; | ||
|
||
namespace Xamarin.RevenueCat.iOS.Extensions | ||
{ | ||
public class PurchaseSuccessInfo | ||
{ | ||
public SKPaymentTransaction Transaction { get; } | ||
public RCPurchaserInfo PurchaserInfo { get; } | ||
|
||
public PurchaseSuccessInfo(SKPaymentTransaction transaction, RCPurchaserInfo purchaserInfo) | ||
{ | ||
Transaction = transaction; | ||
PurchaserInfo = purchaserInfo; | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
Xamarin.RevenueCat.iOS.Extensions/RCPurchasesExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Foundation; | ||
using Purchases; | ||
using StoreKit; | ||
using Xamarin.RevenueCat.iOS.Extensions.Exceptions; | ||
|
||
namespace Xamarin.RevenueCat.iOS.Extensions | ||
{ | ||
public static class RCPurchasesExtensions | ||
{ | ||
public static Task<RCOfferings> GetOfferingsAsync(this RCPurchases purchases, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = new TaskCompletionSource<RCOfferings>(); | ||
cancellationToken.Register(() => tcs.TrySetCanceled()); | ||
purchases.OfferingsWithCompletionBlock((RCOfferings offerings, NSError error) => | ||
{ | ||
if (error != null) | ||
{ | ||
tcs.TrySetException(new PurchasesErrorException(error, false)); | ||
} | ||
|
||
tcs.TrySetResult(offerings); | ||
}); | ||
return tcs.Task; | ||
} | ||
|
||
public static Task<PurchaseSuccessInfo> PurchasePackageAsync(this RCPurchases purchases, | ||
RCPackage packageToPurchase, CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = new TaskCompletionSource<PurchaseSuccessInfo>(); | ||
cancellationToken.Register(() => tcs.TrySetCanceled()); | ||
purchases.PurchasePackage(packageToPurchase, | ||
(SKPaymentTransaction transaction, RCPurchaserInfo purchaserInfo, NSError error, bool userCancelled) => | ||
{ | ||
if (error != null) | ||
{ | ||
tcs.TrySetException(new PurchasesErrorException(error, userCancelled)); | ||
} | ||
|
||
if (userCancelled) | ||
{ | ||
tcs.TrySetException(new PurchasesErrorException(null, true)); | ||
} | ||
|
||
tcs.TrySetResult(new PurchaseSuccessInfo(transaction, purchaserInfo)); | ||
}); | ||
return tcs.Task; | ||
} | ||
|
||
public static Task<RCPurchaserInfo> RestoreTransactionsAsync(this RCPurchases purchases, CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = new TaskCompletionSource<RCPurchaserInfo>(); | ||
cancellationToken.Register(() => tcs.TrySetCanceled()); | ||
purchases.RestoreTransactionsWithCompletionBlock((RCPurchaserInfo purchaserInfo, NSError error) => | ||
{ | ||
if (error != null) | ||
{ | ||
tcs.TrySetException(new PurchasesErrorException(error, false)); | ||
} | ||
|
||
tcs.TrySetResult(purchaserInfo); | ||
}); | ||
return tcs.Task; | ||
} | ||
|
||
public static Task<RCPurchaserInfo> GetPurchaserInfoAsync(this RCPurchases purchases, CancellationToken cancellationToken = default) | ||
{ | ||
var tcs = new TaskCompletionSource<RCPurchaserInfo>(); | ||
cancellationToken.Register(() => tcs.TrySetCanceled()); | ||
purchases.PurchaserInfoWithCompletionBlock((RCPurchaserInfo purchaserInfo, NSError error) => | ||
{ | ||
if (error != null) | ||
{ | ||
tcs.TrySetException(new PurchasesErrorException(error, false)); | ||
} | ||
|
||
tcs.TrySetResult(purchaserInfo); | ||
}); | ||
return tcs.Task; | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Xamarin.RevenueCat.iOS.Extensions/Xamarin.RevenueCat.iOS.Extensions.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<PackageId>Xamarin.RevenueCat.iOS.Extensions</PackageId> | ||
<Description>Contains convenience methods and async extensions for Xamarin.RevenueCat.iOS</Description> | ||
<Version>3.5.3.5</Version> | ||
<Authors>Christian Kapplmüller</Authors> | ||
<Company>fun.music IT GmbH</Company> | ||
<PackageOutputPath>nugetoutput</PackageOutputPath> | ||
<PackageLicensePath>..\..\..\LICENSE.txt</PackageLicensePath> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{9774C184-1A52-40A3-82F7-3D27F92AD38E}</ProjectGuid> | ||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<TemplateGuid>{a52b8a63-bc84-4b47-910d-692533484892}</TemplateGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>Xamarin.RevenueCat.iOS.Extensions</RootNamespace> | ||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> | ||
<AssemblyName>Xamarin.RevenueCat.iOS.Extensions</AssemblyName> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>full</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Xamarin.iOS" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="RCPurchasesExtensions.cs" /> | ||
<Compile Include="Exceptions\PurchasesErrorException.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="PurchaseSuccessInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="5.7.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Xamarin.RevenueCat.iOS\Xamarin.RevenueCat.iOS.csproj"> | ||
<Project>{EAA9C04E-CFAD-49D2-A3A8-168A811D79DA}</Project> | ||
<Name>Xamarin.RevenueCat.iOS</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> | ||
</Project> |
57 changes: 57 additions & 0 deletions
57
Xamarin.RevenueCat.iOS.Extensions/azure-pipeline-public-nuget-publish.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
trigger: | ||
branches: | ||
include: | ||
- refs/tags/release-extensions-v* | ||
|
||
pool: | ||
vmImage: 'macOS-10.15' | ||
|
||
variables: | ||
- group: tonestro.private.artifacts | ||
|
||
steps: | ||
|
||
- bash: | | ||
echo "##vso[task.setvariable variable=bindingsVersion]$(cat Xamarin.RevenueCat.iOS/Xamarin.RevenueCat.iOS.csproj | grep '<Version>' | awk -F '[<>]' '{print $3}')" | ||
- bash: | | ||
echo "##vso[build.updatebuildnumber]xamarin-revenuecat-ios-extensions-$(Build.SourceBranchName)-$(Build.BuildId)" | ||
- bash: | | ||
if [[ "$(Build.SourceBranchName)" != *"$(bindingsVersion)" ]]; then | ||
echo "mismatch between tag $(Build.SourceBranchName) and nuget version $(bindingsVersion)" | ||
exit 1 | ||
fi | ||
- bash: | | ||
cd Xamarin.RevenueCat.iOS.Extensions | ||
msbuild /t:Restore /p:Configuration=Release | ||
msbuild /t:Build /p:Configuration=Release | ||
msbuild /t:Pack /p:Configuration=Release | ||
- task: NuGetAuthenticate@0 | ||
displayName: 'NuGet Authenticate' | ||
- task: NuGetCommand@2 | ||
displayName: 'NuGet push' | ||
inputs: | ||
command: 'push' | ||
packagesToPush: 'Xamarin.RevenueCat.iOS.Extensions/nugetoutput/Xamarin.RevenueCat.iOS.Extensions.*.nupkg' | ||
nuGetFeedType: 'internal' | ||
publishVstsFeed: '95a4928e-7a26-4e37-a11b-e681e1d9910c' | ||
allowPackageConflicts: true | ||
|
||
#- bash: | | ||
# dotnet nuget push Xamarin.RevenueCat.iOS.Extensions/nugetoutput/Xamarin.RevenueCat.iOS.Extensions.*.nupkg -k "$(azureDevOpsRepoApiKey)" -s "$(azureDevOpsRepoTargetUrl)" | ||
|
||
#- task: GitHubRelease@1 | ||
# inputs: | ||
# gitHubConnection: 'github.com_thisisthekap' | ||
# repositoryName: 'thisisthekap/Xamarin.RevenueCat.iOS' | ||
# action: 'create' | ||
# target: '$(Build.SourceVersion)' | ||
# tagSource: 'userSpecifiedTag' | ||
# tag: '$(Build.SourceBranchName)' | ||
# title: 'Xamarin.RevenueCat.iOS.Extensions $(bindingsVersion)' | ||
# assets: 'Xamarin.RevenueCat.iOS.Extensions/nugetoutput/Xamarin.RevenueCat.iOS.Extensions.*.nupkg' | ||
# changeLogCompareToRelease: 'lastFullRelease' | ||
# changeLogType: 'issueBased' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.