Skip to content

Commit

Permalink
[PassKit] Implement Xcode 16.0 beta 1-6 changes. (#21139)
Browse files Browse the repository at this point in the history
Note: there were no changes in beta 3, beta 4 or beta 5.
  • Loading branch information
rolfbjarne authored Sep 12, 2024
1 parent 17d27c9 commit f7bddc6
Show file tree
Hide file tree
Showing 18 changed files with 383 additions and 296 deletions.
3 changes: 3 additions & 0 deletions src/PassKit/PKCompat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public partial class PKDisbursementRequest {
#if NET
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif // NET
[EditorBrowsable (EditorBrowsableState.Never)]
Expand All @@ -186,6 +187,7 @@ public virtual NSDecimalNumber Amount {
#if NET
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif // NET
[EditorBrowsable (EditorBrowsableState.Never)]
Expand All @@ -198,6 +200,7 @@ public virtual string CountryCode {
#if NET
[UnsupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("ios")]
[UnsupportedOSPlatform ("tvos")]
[UnsupportedOSPlatform ("maccatalyst")]
#endif // NET
[EditorBrowsable (EditorBrowsableState.Never)]
Expand Down
23 changes: 20 additions & 3 deletions src/PassKit/PKEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public enum PKAddPaymentPassError : long {

/// <summary>Enumerates results that are used in calls to <see cref="M:PassKit.PKPassLibrary.RequestAutomaticPassPresentationSuppression(System.Action{PassKit.PKAutomaticPassPresentationSuppressionResult})" />.</summary>
[Mac (11, 0)]
[NoWatch]
[Watch (10, 2)]
[MacCatalyst (13, 1)]
[Native]
public enum PKAutomaticPassPresentationSuppressionResult : ulong {
Expand Down Expand Up @@ -333,7 +333,15 @@ public enum PKAddPaymentPassStyle : ulong {
[ErrorDomain ("PKAddSecureElementPassErrorDomain")]
[Native]
public enum PKAddSecureElementPassErrorCode : long {
UnknownError,
GenericError = 0,
#if !XAMCORE_5_0
[Deprecated (PlatformName.iOS, 18, 0, message: "Use 'GenericError' instead.")]
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use 'GenericError' instead.")]
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use 'GenericError' instead.")]
[Deprecated (PlatformName.WatchOS, 11, 0, message: "Use 'GenericError' instead.")]
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'GenericError' instead.")]
UnknownError = GenericError,
#endif
UserCanceledError,
UnavailableError,
InvalidConfigurationError,
Expand Down Expand Up @@ -370,6 +378,7 @@ public enum PKIdentityError : long {
RequestAlreadyInProgress = 5,
InvalidNonce = 6,
InvalidElement = 7,
RegionNotSupported = 8,
}

[iOS (16, 0), Mac (13, 0), Watch (9, 0), NoTV, MacCatalyst (16, 0)]
Expand Down Expand Up @@ -413,7 +422,7 @@ public enum PKApplePayLaterAvailability : long {
UnavailableRecurringTransaction,
}

[NoWatch, NoTV, NoMac, iOS (17, 0), MacCatalyst (17, 0)]
[NoWatch, NoTV, Mac (15, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Native]
[ErrorDomain ("PKDisbursementErrorDomain")]
public enum PKDisbursementErrorCode : long {
Expand All @@ -437,4 +446,12 @@ public enum PKPayLaterDisplayStyle : long {
Checkout,
Price,
}

[Static]
[Internal]
[Watch (11, 0), TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
interface PKMerchantCategoryCodeValues {
[Field ("PKMerchantCategoryCodeNone")]
short None { get; }
}
}
36 changes: 36 additions & 0 deletions src/PassKit/PKJapanIndividualNumberCardMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#nullable enable

#if !WATCH

using System;
using Foundation;
using ObjCRuntime;

namespace PassKit {

/// <summary>This enum is used to select how to initialize a new instance of a <see cref="PKJapanIndividualNumberCardMetadata" />.</summary>
public enum PKJapanIndividualNumberCardMetadataConstructorOption {
/// <summary>The <c>cardIdentifier</c> parameter passed to the constructor is an card template identifier.</summary>
CardTemplateIdentifier,
/// <summary>The <c>cardIdentifier</c> parameter passed to the constructor is an card configuration identifier.</summary>
CardConfigurationIdentifier,
}

public partial class PKJapanIndividualNumberCardMetadata {
public PKJapanIndividualNumberCardMetadata (string credentialIdentifier, string sharingInstanceIdentifier, string cardIdentifier, PKAddPassMetadataPreview preview, PKJapanIndividualNumberCardMetadataConstructorOption option)
: base (NSObjectFlag.Empty)
{
switch (option) {
case PKJapanIndividualNumberCardMetadataConstructorOption.CardTemplateIdentifier:
InitializeHandle (_InitWithProvisioningCredentialIdentifier_CardTemplateIdentifier (credentialIdentifier, sharingInstanceIdentifier, cardIdentifier, preview)); ;
break;
case PKJapanIndividualNumberCardMetadataConstructorOption.CardConfigurationIdentifier:
InitializeHandle (_InitWithProvisioningCredentialIdentifier_CardConfigurationIdentifier (credentialIdentifier, sharingInstanceIdentifier, cardIdentifier, preview));
break;
default:
throw new ArgumentOutOfRangeException (nameof (option), option, "Invalid enum value.");
}
}
}
}
#endif // !WATCH
70 changes: 70 additions & 0 deletions src/PassKit/PKMerchantCategoryCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Runtime.Versioning;

using ObjCRuntime;

#nullable enable

#if !NET
using NativeHandle = System.IntPtr;
#endif

#if !TVOS

namespace PassKit {
/*
* PKMerchantCategoryCode is defined like this:
*
* typedef SInt16 PKMerchantCategoryCode NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0));
* extern PKMerchantCategoryCode const PKMerchantCategoryCodeNone API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0));
*
* In other words: like a strongly typed enum, just with 'short' as the backing type instead of 'NSString'.
*
* Since we can't model this as an enum in C# (because the values aren't constant), instead create a custom struct with a short field.
*/

/// <summary>The four-digit type, in ISO 18245 format, that represents the type of goods or service a merchant provides for a transaction.</summary>
#if NET
[SupportedOSPlatform ("macos15.0")]
[SupportedOSPlatform ("ios18.0")]
[SupportedOSPlatform ("maccatalyst18.0")]
[UnsupportedOSPlatform ("tvos")]
#else
[Mac (15, 0), iOS (18, 0), NoTV, MacCatalyst (18, 0), Watch (11, 0)]
#endif
public struct PKMerchantCategoryCode {
short value;

#if !COREBUILD
/// <summary>A <see cref="PKMerchantCategoryCode" /> representing no merchant code.</summary>
public static PKMerchantCategoryCode None { get => new PKMerchantCategoryCode (PKMerchantCategoryCodeValues.None); }
#endif

/// <summary>Create a <see cref="PKMerchantCategoryCode" /> for the specified merchant code.</summary>
/// <param name="code">The 16-bit merchant code.</param>
public PKMerchantCategoryCode (short code)
{
value = code;
}

/// <summary>Get the 16-bit value for this <see cref="PKMerchantCategoryCode" />.</summary>
public short Value {
get {
return this.Value;
}
}

/// <summary>Get the 16-bit value for a <see cref="PKMerchantCategoryCode" />.</summary>
public static explicit operator short (PKMerchantCategoryCode code)
{
return code.Value;
}

/// <summary>Convert a 16-bit value to a <see cref="PKMerchantCategoryCode" />.</summary>
public static explicit operator PKMerchantCategoryCode (short code)
{
return new PKMerchantCategoryCode (code);
}
}
}
#endif // !TVOS
6 changes: 5 additions & 1 deletion src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1512,9 +1512,13 @@ OPENGLES_SOURCES = \

PASSKIT_API_SOURCES = \
PassKit/PKEnums.cs \


PASSKIT_CORE_SOURCES = \
PassKit/PKMerchantCategoryCode.cs \

PASSKIT_SOURCES = \
PassKit/PKCompat.cs \
PassKit/PKJapanIndividualNumberCardMetadata.cs \
PassKit/PKPayLaterView.cs \
PassKit/PKPaymentRequest.cs \
PassKit/PKShareablePassMetadata.cs \
Expand Down
Loading

4 comments on commit f7bddc6

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.