- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Adds method passes to retrieve any available passes #9
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -28,6 +28,18 @@ @implementation RNWalletModule | |
| callback(@[@([PKAddPassesViewController canAddPasses])]); | ||
| } | ||
|  | ||
| RCT_EXPORT_METHOD( | ||
| passes:(RCTResponseSenderBlock)callback | ||
| ) { | ||
| self.passLibrary = [[PKPassLibrary alloc] init]; | ||
| NSArray *passes = [self.passLibrary passes]; | ||
|  | ||
| NSDictionary *dict = [NSDictionary dictionaryWithObjects:passes forKeys:[passes valueForKey:@"serialNumber"]]; | ||
| NSArray*serials=[dict allKeys]; | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you're trying to reduce an array of passes to an array of serialnumbers? | ||
|  | ||
| callback(@[[NSNull null], serials]); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use the Node convention of passing null instead on an error in this project. | ||
| } | ||
|  | ||
| RCT_EXPORT_METHOD( | ||
| showAddPassControllerFromFile:(NSString *)filepath | ||
| resolver:(RCTPromiseResolveBlock)resolve | ||
|  | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| import { NativeModules } from 'react-native'; | ||
| const { RNWalletModule } = NativeModules; | ||
| import { _canAddPasses, _showAddPassControllerFromURL, _showAddPassControllerFromFile } from './platform-specific'; | ||
| import { NativeModules } from 'react-native' | ||
| import { | ||
| _canAddPasses, | ||
| _showAddPassControllerFromURL, | ||
| _showAddPassControllerFromFile, | ||
| _passes | ||
| } from './platform-specific' | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Respecting the print line 🕺 | ||
| const { RNWalletModule } = NativeModules | ||
|  | ||
| /** | ||
| * Check if you can add passes. | ||
|  | @@ -17,7 +22,7 @@ function canAddPasses(callback) { | |
| * @return Promise Passing a boolean | ||
| */ | ||
| function showAddPassControllerFromURL(passURL) { | ||
| return _showAddPassControllerFromURL(RNWalletModule, passURL); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤨 | ||
| return _showAddPassControllerFromURL(RNWalletModule, passURL) | ||
| } | ||
|  | ||
| /** | ||
|  | @@ -27,11 +32,16 @@ function showAddPassControllerFromURL(passURL) { | |
| * @return Promise Passing a boolean | ||
| */ | ||
| function showAddPassControllerFromFile(filepath) { | ||
| return _showAddPassControllerFromFile(RNWalletModule, filepath); | ||
| return _showAddPassControllerFromFile(RNWalletModule, filepath) | ||
| } | ||
|  | ||
| function passes(callback) { | ||
| _passes(RNWalletModule, callback) | ||
| } | ||
|  | ||
| module.exports = { | ||
| canAddPasses, | ||
| showAddPassControllerFromURL, | ||
| showAddPassControllerFromFile | ||
| showAddPassControllerFromFile, | ||
| passes | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel this is very readable