Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PassKit] Update bindings for Xcode 13.0 beta 1, 2 #12299

Merged
merged 5 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/PassKit/PKEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public enum PKPaymentButtonType : long {
Contribute = 14,
[iOS (14,0)]
Tip = 15,
[Mac (12,0), iOS (15,0), Watch (8,0)]
Continue = 16,
}

[Mac (11,0)]
Expand Down Expand Up @@ -221,17 +223,8 @@ public enum PKPaymentMethodType : ulong
Debit,
Credit,
Prepaid,
Store
}

[Mac (11,0)]
[Watch (3,0)]
[iOS (9,0)]
[Native]
public enum PKPaymentSummaryItemType : ulong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a breaking change to remove this enum type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh oops! thanks for catching that - diffs removed and added back and I totally missed it

{
Final,
Pending
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we add these in this cycle?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, confusing diffs threw me off-course here! fixing

Store,
EMoney,
}

[NoWatch]
Expand All @@ -252,6 +245,8 @@ public enum PKPaymentErrorCode : long {
ShippingContactInvalid = 1,
BillingContactInvalid,
ShippingAddressUnserviceable,
CouponCodeInvalid,
CouponCodeExpired,
}

[iOS (12,0)]
Expand Down
218 changes: 206 additions & 12 deletions src/passkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ interface PKPassLibrary {
[Watch (6,2), iOS (13,4)]
[Export ("signData:withSecureElementPass:completion:")]
void SignData (NSData signData, PKSecureElementPass secureElementPass, PKPassLibrarySignDataCompletionHandler completion);

[Async (ResultTypeName = "PKServiceProviderDataCompletionResult")]
[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[Export ("serviceProviderDataForSecureElementPass:completion:")]
void ServiceProviderData (PKSecureElementPass secureElementPass, Action<NSData, NSError> completion);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a verb, right? CreateServiceProviderData maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method needs a verb/action, prefix with Get

Calls a completion handler that returns the custom data for a Secure Element pass
https://developer.apple.com/documentation/passkit/pkpasslibrary/3747078-serviceproviderdataforsecureelem

}

[Static]
Expand Down Expand Up @@ -345,6 +350,11 @@ interface PKPaymentAuthorizationViewControllerDelegate {
[Export ("paymentAuthorizationViewController:didRequestMerchantSessionUpdate:")]
[EventArgs ("PKPaymentRequestMerchantSessionUpdate")]
void DidRequestMerchantSessionUpdate (PKPaymentAuthorizationViewController controller, Action<PKPaymentRequestMerchantSessionUpdate> updateHandler);

[NoWatch, Mac (12,0), iOS (15,0)]
[Export ("paymentAuthorizationViewController:didChangeCouponCode:handler:")]
[EventArgs ("PKPaymentRequestCouponCodeUpdate")]
void DidChangeCouponCode (PKPaymentAuthorizationViewController controller, string couponCode, Action<PKPaymentRequestCouponCodeUpdate> completion);
}

[Mac (11,0)]
Expand Down Expand Up @@ -416,6 +426,11 @@ interface PKShippingMethod {
[NullAllowed] // by default this property is null
[Export ("detail")]
string Detail { get; set; }

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[NullAllowed]
[Export ("dateComponentsRange", ArgumentSemantic.Copy)]
PKDateComponentsRange DateComponentsRange { get; set; }
}

[Watch (3,0)]
Expand Down Expand Up @@ -446,6 +461,19 @@ interface PKPaymentRequest {
[Export ("currencyCode")]
string CurrencyCode { get; set; }

[NoWatch, Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("supportsCouponCode")]
bool SupportsCouponCode { get; set; }

[NullAllowed]
[NoWatch, Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("couponCode")]
string CouponCode { get; set; }

[Watch (8,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("shippingContactEditingMode", ArgumentSemantic.Assign)]
PKShippingContactEditingMode ShippingContactEditingMode { get; set; }

[NoMac]
[Deprecated (PlatformName.WatchOS, 4,0, message: "Use 'RequiredBillingContactFields' instead.")]
[Deprecated (PlatformName.iOS, 11,0, message: "Use 'RequiredBillingContactFields' instead.")]
Expand Down Expand Up @@ -548,6 +576,16 @@ interface PKPaymentRequest {
[Static]
[Export ("paymentShippingAddressUnserviceableErrorWithLocalizedDescription:")]
NSError CreatePaymentShippingAddressUnserviceableError ([NullAllowed] string localizedDescription);

[NoWatch, Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Static]
[Export ("paymentCouponCodeInvalidErrorWithLocalizedDescription:")]
NSError CouponCodeInvalidError ([NullAllowed] string localizedDescription);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, Is this starting with a verb?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix with Get


[NoWatch, Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Static]
[Export ("paymentCouponCodeExpiredErrorWithLocalizedDescription:")]
NSError CouponCodeExpiredError ([NullAllowed] string localizedDescription);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix with Get

}

[Mac (11,0)]
Expand Down Expand Up @@ -1140,7 +1178,11 @@ interface PKPaymentAuthorizationControllerDelegate {
[MacCatalyst (14,0)]
[Export ("paymentAuthorizationController:didRequestMerchantSessionUpdate:")]
void DidRequestMerchantSessionUpdate (PKPaymentAuthorizationController controller, Action<PKPaymentRequestMerchantSessionUpdate> handler);


[NoWatch, Mac (12,0), iOS (15,0)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MacCatalyst (15,0)] ?
otherwise it's implied it existed in 13.0 (the original release)

[Export ("paymentAuthorizationController:didChangeCouponCode:handler:")]
void DidChangeCouponCode (PKPaymentAuthorizationController controller, string couponCode, Action<PKPaymentRequestCouponCodeUpdate> completion);

[Watch (7,0)][iOS (14,0)]
[MacCatalyst (14,0)]
[Export ("presentationWindowForPaymentAuthorizationController:")]
Expand Down Expand Up @@ -1171,27 +1213,29 @@ interface PKLabeledValue

[Mac (11,0)]
[Watch (4,3), iOS (11,3)]
[BaseType (typeof (NSObject))]
[BaseType (typeof (PKStoredValuePassProperties))]
[DisableDefaultCtor]
interface PKTransitPassProperties {

[Static]
[Export ("passPropertiesForPass:")]
[return: NullAllowed]
PKTransitPassProperties GetPassProperties (PKPass pass);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a breaking change to remove this API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I see diffs like -+ (nullable instancetype)passPropertiesForPass:(PKPass *)pass; for something that leads to a breaking change, should I just ignore it then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more context

+ (nullable instancetype)passPropertiesForPass:(PKPass *)pass;

looks identical to what we already have. I could be because the header moved the definition or duplicated a member in a subclass...

In any case we must find a way to expose new API without breaking changes


[Deprecated (PlatformName.iOS, 15, 0)]
[Deprecated (PlatformName.WatchOS, 8, 0)]
[Deprecated (PlatformName.MacOSX, 12, 0)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacCatalyst?

[Export ("transitBalance", ArgumentSemantic.Copy)]
NSDecimalNumber TransitBalance { get; }

[Deprecated (PlatformName.iOS, 15, 0)]
[Deprecated (PlatformName.WatchOS, 8, 0)]
[Deprecated (PlatformName.MacOSX, 12, 0)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, MacCatalyst?

[Export ("transitBalanceCurrencyCode")]
string TransitBalanceCurrencyCode { get; }

[Export ("inStation")]
bool InStation { [Bind ("isInStation")] get; }

[Deprecated (PlatformName.iOS, 14,5, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.MacCatalyst, 14,5, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.WatchOS, 7,4, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.iOS, 15, 0, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.MacCatalyst, 15, 0, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.WatchOS, 8, 0, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.MacOSX, 12, 0, message: "Use 'Blocked' instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocked availability was earlier (see below) so the deprecated should not change - except that macOS should have one for 11,3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, looks like I got confused with a different blocked - thanks for catching!

[Export ("blacklisted")]
bool Blacklisted { [Bind ("isBlacklisted")] get; }

Expand Down Expand Up @@ -1242,8 +1286,8 @@ interface PKSuicaPassProperties
bool GreenCarTicketUsed { [Bind ("isGreenCarTicketUsed")] get; }

[Export ("blacklisted")]
[Deprecated (PlatformName.iOS, 14,5, message: "Use 'Blocked' instead.")] // exists in base class
[Deprecated (PlatformName.WatchOS, 7,4, message: "Use 'Blocked' instead.")]
[Deprecated (PlatformName.iOS, 15, 0, message: "Use 'Blocked' instead.")] // exists in base class
[Deprecated (PlatformName.WatchOS, 8, 0, message: "Use 'Blocked' instead.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, MacCatalyst?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, the version should be the one where Blocked was added
and it's also missing one for macOS 11,0 and (likely Catalyst)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

just to confirm, are the web docs misleading about this one? clicking on the hyperlink goes to the blocked property for pkstoredvaluepassproperties instead of pktransitpassproperties https://developer.apple.com/documentation/passkit/pksuicapassproperties/2545174-blacklisted?language=objc

bool Blacklisted { [Bind ("isBlacklisted")] get; }
}

Expand Down Expand Up @@ -1278,6 +1322,10 @@ interface PKPaymentRequestUpdate {

[Export ("paymentSummaryItems", ArgumentSemantic.Copy)]
PKPaymentSummaryItem[] PaymentSummaryItems { get; set; }

[Watch (8,0), Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[Export ("shippingMethods", ArgumentSemantic.Copy)]
PKShippingMethod[] ShippingMethods { get; set; }
}

[Mac (11,0)]
Expand Down Expand Up @@ -1569,6 +1617,10 @@ interface PKShareablePassMetadata {
[Export ("initWithProvisioningCredentialIdentifier:cardConfigurationIdentifier:sharingInstanceIdentifier:passThumbnailImage:ownerDisplayName:localizedDescription:")]
IntPtr Constructor (string credentialIdentifier, string cardConfigurationIdentifier, string sharingInstanceIdentifier, CGImage passThumbnailImage, string ownerDisplayName, string localizedDescription);

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[Export ("initWithProvisioningCredentialIdentifier:sharingInstanceIdentifier:passThumbnailImage:ownerDisplayName:localizedDescription:accountHash:templateIdentifier:relyingPartyIdentifier:requiresUnifiedAccessCapableDevice:")]
IntPtr Constructor (string credentialIdentifier, string sharingInstanceIdentifier, CGImage passThumbnailImage, string ownerDisplayName, string localizedDescription, string accountHash, string templateIdentifier, string relyingPartyIdentifier, bool requiresUnifiedAccessCapableDevice);

[Export ("credentialIdentifier", ArgumentSemantic.Strong)]
string CredentialIdentifier { get; }

Expand All @@ -1586,6 +1638,22 @@ interface PKShareablePassMetadata {

[Export ("ownerDisplayName", ArgumentSemantic.Strong)]
string OwnerDisplayName { get; }

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[Export ("accountHash", ArgumentSemantic.Strong)]
string AccountHash { get; }

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[Export ("templateIdentifier", ArgumentSemantic.Strong)]
string TemplateIdentifier { get; }

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[Export ("relyingPartyIdentifier", ArgumentSemantic.Strong)]
string RelyingPartyIdentifier { get; }

[iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing [Watch]
this implies it was available in watchOS 2.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do I determine the availability when the docs don't indicate them and I can't find the relevant header file? (I'm assuming in this case that it's Watch (8, 0) but can never be too sure)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rachelkang if it does, look at the diff:

+                      requiresUnifiedAccessCapableDevice:(BOOL)requiresUnifiedAccessCapableDevice
 API_AVAILABLE(ios(15.0), watchos(8.0));

So, iOS 15 and watch 8 :) From https://github.com/xamarin/xamarin-macios/wiki/PassKit-iOS-xcode13.0-beta2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I totally missed that... they are so inconsistent!!! thanks 😆

[Export ("requiresUnifiedAccessCapableDevice")]
bool RequiresUnifiedAccessCapableDevice { get; }
}

[NoWatch, NoTV]
Expand Down Expand Up @@ -1858,6 +1926,23 @@ interface PKPaymentRequestMerchantSessionUpdate {
PKPaymentMerchantSession Session { get; set; }
}

[NoWatch, Mac (12,0), iOS (15,0), MacCatalyst (15,0)]
[BaseType (typeof(PKPaymentRequestUpdate))]
[DisableDefaultCtor]
interface PKPaymentRequestCouponCodeUpdate
{
[Export ("initWithPaymentSummaryItems:")]
[DesignatedInitializer]
IntPtr Constructor (PKPaymentSummaryItem[] paymentSummaryItems);

[Export ("initWithErrors:paymentSummaryItems:shippingMethods:")]
[DesignatedInitializer]
IntPtr Constructor ([NullAllowed] NSError[] errors, PKPaymentSummaryItem[] paymentSummaryItems, PKShippingMethod[] shippingMethods);

[NullAllowed, Export ("errors", ArgumentSemantic.Copy)]
NSError[] Errors { get; set; }
}

[Watch (7,0)][Mac (11,0)][iOS (14,0)]
[MacCatalyst (14,0)]
[BaseType (typeof (NSObject))]
Expand All @@ -1873,4 +1958,113 @@ enum PKRadioTechnology : ulong {
Nfc = 1 << 0,
Bluetooth = 1 << 1,
}

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface PKDateComponentsRange : NSCopying, NSSecureCoding
{
[Export ("initWithStartDateComponents:endDateComponents:")]
[return: NullAllowed]
IntPtr Constructor (NSDateComponents startDateComponents, NSDateComponents endDateComponents);

[Export ("startDateComponents", ArgumentSemantic.Copy)]
NSDateComponents StartDateComponents { get; }

[Export ("endDateComponents", ArgumentSemantic.Copy)]
NSDateComponents EndDateComponents { get; }
}

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[BaseType (typeof(PKPaymentSummaryItem))]
[DisableDefaultCtor]
interface PKDeferredPaymentSummaryItem
{
[Export ("deferredDate", ArgumentSemantic.Copy)]
NSDate DeferredDate { get; set; }
}

[Watch (8,0), Mac (12,0), iOS (15,0)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac Catalyst?

[Native]
public enum PKShippingContactEditingMode : ulong
{
Enabled = 1,
StorePickup,
}

[Watch (3,0), iOS (9,0)]
[Native]
public enum PKPaymentSummaryItemType : ulong
{
Final,
Pending,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ ideally avoid moving types - it makes reviewing harder (and my earlier comment about a breaking change likely incorrect)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! sorry - as mentioned in the other comment, the diffs removed and re-added them later which threw me off-course here


[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[BaseType (typeof(PKPaymentSummaryItem))]
[DisableDefaultCtor]
interface PKRecurringPaymentSummaryItem
{
[NullAllowed, Export ("startDate", ArgumentSemantic.Copy)]
NSDate StartDate { get; set; }

[Export ("intervalUnit", ArgumentSemantic.Assign)]
NSCalendarUnit IntervalUnit { get; set; }

[Export ("intervalCount")]
nint IntervalCount { get; set; }

[NullAllowed, Export ("endDate", ArgumentSemantic.Copy)]
NSDate EndDate { get; set; }
}

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
public enum PKStoredValuePassBalanceType : ulong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove the : ulong since it's not [Native] anymore

{
[Field ("PKStoredValuePassBalanceTypeCash")]
Cash,
[Field ("PKStoredValuePassBalanceTypeLoyaltyPoints")]
LoyaltyPoints,
}

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface PKStoredValuePassBalance
{
[Export ("amount", ArgumentSemantic.Strong)]
NSDecimalNumber Amount { get; }

[NullAllowed, Export ("currencyCode")]
string CurrencyCode { get; }

[Export ("balanceType")]
string BalanceType { get; }

[NullAllowed, Export ("expiryDate", ArgumentSemantic.Strong)]
NSDate ExpiryDate { get; }

[Export ("isEqualToBalance:")]
bool IsEqualToBalance (PKStoredValuePassBalance balance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> IsEqual since Balance: is the argument part of the selector

}

[Watch (8,0), iOS (15,0), Mac (12,0), MacCatalyst (15,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface PKStoredValuePassProperties
{
[Static]
[Export ("passPropertiesForPass:")]
[return: NullAllowed]
PKStoredValuePassProperties PassPropertiesForPass (PKPass pass);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> GetPassProperties


[Export ("blocked")]
bool Blocked { [Bind ("isBlocked")] get; }

[NullAllowed, Export ("expirationDate", ArgumentSemantic.Copy)]
NSDate ExpirationDate { get; }

[Export ("balances", ArgumentSemantic.Copy)]
PKStoredValuePassBalance[] Balances { get; }
}
}
13 changes: 13 additions & 0 deletions tests/introspection/iOS/iOSApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ protected override bool Skip (Type type, string protocolName)
case "ARSkeletonDefinition": // device only
case "ARVideoFormat": // device only
case "NSMergePolicy":
case "PKDeferredPaymentSummaryItem":
case "PKPaymentRequestCouponCodeUpdate":
case "PKRecurringPaymentSummaryItem":
case "PKStoredValuePassBalance":
case "PKStoredValuePassProperties":
case "SFSafariViewControllerPrewarmingToken": // conformance not in headers
case "SRTextInputSession": // conformance not in headers
return true;
Expand Down Expand Up @@ -682,6 +687,11 @@ protected override bool Skip (Type type, string protocolName)
case "ARSkeletonDefinition": // device only
case "ARVideoFormat": // device only
case "NSMergePolicy":
case "PKDeferredPaymentSummaryItem":
case "PKPaymentRequestCouponCodeUpdate":
case "PKRecurringPaymentSummaryItem":
case "PKStoredValuePassBalance":
case "PKStoredValuePassProperties":
case "SFSafariViewControllerPrewarmingToken": // conformance not in headers
case "SRTextInputSession": // conformance not in headers
return true;
Expand Down Expand Up @@ -765,6 +775,9 @@ protected override bool Skip (Type type, string protocolName)
case "NSMappingModel":
case "NSMergePolicy":
case "NSPropertyMapping":
case "PKDeferredPaymentSummaryItem":
case "PKRecurringPaymentSummaryItem":
case "PKStoredValuePassProperties":
return true;
}
break;
Expand Down
Loading