Skip to main content

Events

Add-pass result​

addPass, addPasses and addPassJWT resolve when the wallet UI opens. The user's choice arrives as an event:

import { addPassResultListener } from '@reeq/react-native-passkit';

useEffect(
() =>
addPassResultListener((event) => {
switch (event.status) {
case 'success':
break;
case 'cancelled':
break;
case 'error':
console.warn(event.errorType, event.message);
break;
}
}),
[]
);

Or with the hook:

import { useAddPassResult } from '@reeq/react-native-passkit';

const result = useAddPassResult(); // AddPassResultEvent | undefined

How the status is determined​

  • iOS: when the sheet closes, the library checks whether the pass library now contains the pass. If it does, the status is success. Otherwise it is cancelled. iOS never reports error.
  • Android: the status comes from the Google Wallet activity result:
Result codestatuserrorType
RESULT_OKsuccess
RESULT_CANCELEDcancelled
SAVE_ERRORerrorapi (and message explains why)
API_UNAVAILABLEerrorunavailable
INTERNAL_ERRORerrorinternal
anything elseerrorunexpected

Pass library changes​

iOS 0.3.0+

Fires when passes your app can access are added, replaced or removed, whether by your app, the Wallet app or a server push update:

import { passLibraryChangedListener } from '@reeq/react-native-passkit';

useEffect(
() =>
passLibraryChangedListener(({ added, replaced, removed }) => {
console.log(added.length, replaced.length, removed.length);
}),
[]
);

added and replaced are Pass objects. removed only contains identifiers (passTypeIdentifier, serialNumber), because the pass no longer exists.

On Android the listener never fires, and the returned unsubscribe function does nothing.