Xamarin-macios: pkPassLibrary.CanAddPaymentPass API does not return correct values

Created on 6 Aug 2020  路  3Comments  路  Source: xamarin/xamarin-macios

Steps to Reproduce

This is a bit difficult to reproduce as it requires entitlements from Apple. But the basics of it are:

  1. Create iOS project
  2. Add com.apple.developer.payment-pass-provisioning entitlement
  3. Add in check to see if a user can add a PaymentPass:
var pkPassLibrary = new PKPassLibrary();
var canAddPass = pkPassLibrary.CanAddPaymentPass(primaryAccountIdentifier);
  1. Deploy to testFlight (PKPassLibrary only works in testFlight)
  2. Check if pkPassLibrary.CanAddPaymentPass returns the correct value.

Expected Behavior

pkPassLibrary.CanAddPaymentPass should tell me if a user has already added their payment pass to Apple Wallet, so I can show an "Available in Apple Wallet" button instead of an "Add to Apple Wallet" button as well as meet Apple's testing criteria.

Actual Behavior

pkPassLibrary.CanAddPaymentPass always returns true and therefore tells me nothing.

Environment

Visual Studio Community 2019 for Mac
Version 8.6.6 (build 11)
Installation UUID: 7c83b7c0-1cc5-4e28-826a-cfd04b5e88ea
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 610000104

Mono Framework MDK
Runtime:
    Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
    Package version: 610000104

Roslyn (Language Service)
3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

NuGet
Version: 5.6.0.6591

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.302/Sdks
SDK Versions:
    3.1.302
    3.1.301
    3.1.300
    3.0.100
    2.1.700
    2.1.505
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    3.1.6
    3.1.5
    3.1.4
    3.0.0
    2.1.20
    2.1.19
    2.1.18
    2.1.13
    2.1.11
    2.1.9

Xamarin.Profiler
Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 11.5 (16139)
Build 11E608c

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

Xamarin Designer
Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

Xamarin.Android
Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/nickmaskell/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

Microsoft OpenJDK for Mobile
Java SDK: /Users/nickmaskell/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

Android Device Manager
Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

Build Information
Release ID: 806060011
Git revision: c17f4e215fe0a5616b66bbcc3567ee062d168cf0
Build date: 2020-07-14 14:57:14-04
Build branch: release-8.6
Xamarin extensions: c17f4e215fe0a5616b66bbcc3567ee062d168cf0

Operating System
Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
    Tue May 26 20:41:44 PDT 2020
    root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

Build Logs

No errors present. API just does not work.

Example Project (If Possible)

Not possible.

iOS support

Most helpful comment

Hi everyone, thanks for your help.

I did find the issue and @spouliot you are correct. For those that come after me you do need to ensure that you register your associatedApplicationIdentifiers with your payment provider (visa, mastercard, etc). Apple will only let you know about payment passes that are associated with your app. That association is created at the visa/mastercard/etc side of things and is communicated through the panReferenceId.

All 3 comments

@nickmask Thank you for filing this issue!

If it's possible, could you try out the following?

  1. It looks like CanAddPaymentPass is a deprecated API (since iOS 13.4 and WatchOS 6.2). Could you update your code to use the newer API PKPassLibrary.CanAddSecureElementPass and see whether the behavior changes?

  2. Could you try to reproduce the issue in an Xcode project? If it reproduces in Xcode, then it's an Apple bug, not a Xamarin bug. You can file an issue with Apple here: https://feedbackassistant.apple.com

  3. Xamarin.iOS/Xamarin.Mac have support for Xcode 11.6 in any version >= 13.18.1.31. If you update your version of VS and run through the steps for repro again, does the issue still occur?

We look forward to hearing back from you!

@nickmask have a look at https://developer.apple.com/forums/thread/109968

Someone had a similar issue (using ObjC) and the fix was in the back end.

That's becuase the card that has been provisioned (by your backend systems) doesn't contain the application's bundle ID. The field is called associatedApplicationIdentifiers.
See In-App provisioning Getting Started Guide for a deeper explanation.

In 99% of cases our bindings are directs. IOW we do not change what the OS does, we just convert back and forth the arguments between .net and native/objc. Since the API signature is quite simple (accept a string, return a bool) then it's very likely an API usage issue.

Hi everyone, thanks for your help.

I did find the issue and @spouliot you are correct. For those that come after me you do need to ensure that you register your associatedApplicationIdentifiers with your payment provider (visa, mastercard, etc). Apple will only let you know about payment passes that are associated with your app. That association is created at the visa/mastercard/etc side of things and is communicated through the panReferenceId.

Was this page helpful?
0 / 5 - 0 ratings