File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,17 @@ @implementation WalletManager
16
16
17
17
RCT_EXPORT_MODULE (WalletManager);
18
18
19
- RCT_EXPORT_METHOD (canAddPasses:(RCTResponseSenderBlock)callback) {
20
- callback (@[@([PKAddPassesViewController canAddPasses ])]);
19
+ RCT_EXPORT_METHOD (
20
+ canAddPasses:(RCTPromiseResolveBlock)resolve
21
+ rejecter:(RCTPromiseRejectBlock)reject)
22
+ {
23
+ BOOL showPass = [PKAddPassesViewController canAddPasses ];
24
+ if (showPass) {
25
+ resolve (@(YES ));
26
+ return ;
27
+ }
28
+ resolve (@(NO ));
29
+ return ;
21
30
}
22
31
23
32
RCT_EXPORT_METHOD (
Original file line number Diff line number Diff line change 1
1
import { NativeModules , Platform , Linking } from 'react-native' ;
2
2
3
3
type WalletManagerType = {
4
+ canAddPasses ( ) : Promise < boolean > ;
4
5
addPassFromUrl ( url : string ) : Promise < boolean > ;
5
6
hasPass ( cardIdentifier : string , serialNumber ?: string ) : Promise < boolean > ;
6
7
removePass ( cardIdentifier : string , serialNumber ?: string ) : Promise < boolean > ;
@@ -10,6 +11,12 @@ type WalletManagerType = {
10
11
const { WalletManager } = NativeModules ;
11
12
12
13
export default {
14
+ canAddPasses : async ( ) => {
15
+ if ( Platform . OS === 'android' ) {
16
+ throw new Error ( 'canAddPasses method not available on Android' ) ;
17
+ }
18
+ return await WalletManager . canAddPasses ( ) ;
19
+ } ,
13
20
addPassFromUrl :
14
21
Platform . OS === 'ios'
15
22
? WalletManager . addPassFromUrl
You can’t perform that action at this time.
0 commit comments