Skip to content

Commit 146a84a

Browse files
committed
updating documentation for new features
1 parent 2993ba6 commit 146a84a

File tree

2 files changed

+166
-53
lines changed

2 files changed

+166
-53
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# com.passslot.cordova.plugin.passbook
1+
# cordova-plugin-passbook
22

33
This plugin provides support for showing Passbook passs to your users and allows them to add it to their native Wallet (regardless of how you create your passes, whether you do it on your own or using any third-party services like [PassSlot](http://www.PassSlot.com))
44

@@ -14,9 +14,7 @@ Or the latest (unstable) version:
1414

1515
## Supported Platforms
1616

17-
1817
- iOS
19-
- ~~Android~~ (coming soon)
2018

2119
## Example
2220

@@ -25,9 +23,7 @@ Or the latest (unstable) version:
2523
```javascript
2624
Passbook.downloadPass('https://d.pslot.io/cQY2f', function (pass, added) {
2725
console.log(pass, added);
28-
if (added) {
29-
Passbook.openPass(pass);
30-
} else {
26+
if (!added) {
3127
alert('Please add the pass');
3228
}
3329
}, function (error) {
@@ -46,16 +42,43 @@ Or the latest (unstable) version:
4642

4743
Passbook.downloadPass(callData, function (pass, added) {
4844
console.log(pass, added);
49-
if (added) {
50-
Passbook.openPass(pass);
51-
} else {
45+
if (!added) {
5246
alert('Please add the pass');
5347
}
5448
}, function (error) {
5549
console.error(error);
5650
});
5751
```
5852

53+
### Multiple passes
54+
55+
```javascript
56+
Passbook.downloadPasses(['https://d.pslot.io/cQY2f', 'https://d.pslot.io/AeY3D'], function (passes, added) {
57+
console.log(passes, added);
58+
if (!added) {
59+
alert('Please add the passes');
60+
}
61+
}, function (error) {
62+
console.error(error);
63+
});
64+
```
65+
66+
### Multiple passes with headers
67+
68+
```javascript
69+
Passbook.downloadPasses({
70+
urls: ['https://d.pslot.io/cQY2f', 'https://d.pslot.io/AeY3D'],
71+
headers: {authorization: "Bearer <token>"}
72+
}, function (passes, added) {
73+
console.log(passes, added);
74+
if (!added) {
75+
alert('Please add the passes');
76+
}
77+
}, function (error) {
78+
console.error(error);
79+
});
80+
```
81+
5982
## Documentation
6083

6184
Plugin documentation: [doc/index.md](doc/index.md)

doc/index.md

Lines changed: 134 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# com.passslot.cordova.plugin.passbook
1+
# cordova-plugin-passbook
22

33
This plugin provides basic support for Passbook on iOS.
44
It allows you to show Passbook passes so that your users can add them directly to Passbook.
@@ -7,7 +7,7 @@ On cordova >= 3.1.0, this plugin registers for .pkpass URLs and automatically do
77

88
## Installation
99

10-
cordova plugin add com.passslot.cordova.plugin.passbook
10+
cordova plugin add cordova-plugin-passbook
1111

1212
## Supported Platforms
1313

@@ -31,26 +31,25 @@ Returns if Passbook is available on the current device to the `resultCallback` c
3131

3232

3333
### Example
34+
```javascript
35+
// onSuccess Callback
36+
// This method accepts a boolean, which specified if Passbook is available
37+
//
38+
var onResult = function(isAvailable) {
39+
if(!isAvailable) {
40+
alert('Passbook is not available');
41+
}
42+
};
3443

35-
// onSuccess Callback
36-
// This method accepts a boolean, which specified if Passbook is available
37-
//
38-
var onResult = function(isAvailable) {
39-
if(!isAvailable) {
40-
alert('Passbook is not available');
41-
}
42-
};
43-
44-
Passbook.available(onResult);
45-
44+
Passbook.available(onResult);
45+
```
4646
## Passbook.downloadPass
4747

4848
Downloads a pass from a the provided URL and shows it to the user.
4949
When the pass was successfully downloaded and was shown to the user, and the user either canceld or added the pass, the `passCallback` callback executes. If there is an error, the `errorCallback` callback executes with an error string as the parameter
50-
51-
Passbook.downloadPass(callData,
52-
[passCallback],
53-
[errorCallback]);
50+
```javascript
51+
Passbook.downloadPass(callData, [passCallback], [errorCallback]);
52+
```
5453

5554
### Parameters
5655

@@ -64,19 +63,19 @@ When the pass was successfully downloaded and was shown to the user, and the use
6463
### Simple Example
6564

6665
```javascript
67-
// onSuccess Callback
68-
function onSuccess(pass, added) {
69-
console.log('Pass shown to the user');
70-
console.log(pass, added);
71-
}
66+
// onSuccess Callback
67+
function onSuccess(pass, added) {
68+
console.log('Pass shown to the user');
69+
console.log(pass, added);
70+
}
7271

73-
// onError Callback receives a string with the error message
74-
//
75-
function onError(error) {
76-
alert('Could now show pass: ' + error);
77-
}
72+
// onError Callback receives a string with the error message
73+
//
74+
function onError(error) {
75+
alert('Could now show pass: ' + error);
76+
}
7877

79-
Passbook.downloadPass('https://d.pslot.io/cQY2f', onSuccess, onError);
78+
Passbook.downloadPass('https://d.pslot.io/cQY2f', onSuccess, onError);
8079
```
8180

8281
### Adding Header
@@ -99,40 +98,131 @@ var callData = {
9998
"headers":{ "authorization": "Bearer <token>" }
10099
};
101100
Passbook.downloadPass(callData, onSuccess, onError);
101+
```
102+
103+
## Passbook.downloadPasses
104+
105+
Downloads a list of passes from a the provided URLs and shows them to the user.
106+
When the passes are successfully downloaded, shown to the user, and the user either cancelled or added the pass, the `passCallback` callback executes passing an array of passes and a boolean of value of if they were added or not. If there is an error, the `errorCallback` callback executes with an error string as the parameter
107+
```javascript
108+
Passbook.downloadPasses(callData, [passCallback], [errorCallback]);
109+
```
110+
### Parameters
111+
112+
- __callData__: It could be either an array of URL strings or an Object in the form `{ urls:[<url1>,<url2>], headers?:<{}> }` .
113+
114+
- __passCallback__: (Optional) The callback that executes when the pass is shown to the user. Returns the downloaded pass (passTypeIdentifier, serialNumber, passURL) and if it was added to Passbook.
115+
116+
- __errorCallback__: (Optional) The callback that executes if an error occurs, e.g if Passbook is not available, the URL is invalid or no valid pass was found at the given URL.
117+
118+
### Simple Example
119+
120+
```javascript
121+
// onSuccess Callback
122+
function onSuccess(passes, added) {
123+
console.log('Passes shown to the user');
124+
console.log(passes, added);
125+
}
126+
127+
// onError Callback receives a string with the error message
128+
//
129+
function onError(error) {
130+
alert('Could now show passes: ' + error);
131+
}
132+
133+
Passbook.downloadPasses(['https://d.pslot.io/cQY2f', 'https://d.pslot.io/DbM3E'], onSuccess, onError);
134+
```
135+
136+
### Adding Header
102137

138+
```javascript
139+
// onSuccess Callback
140+
function onSuccess(passes, added) {
141+
console.log('Pass shown to the user');
142+
console.log(passes, added);
143+
}
144+
145+
// onError Callback receives a string with the error message
146+
//
147+
function onError(error) {
148+
alert('Could now show passes: ' + error);
149+
}
103150

151+
var callData = {
152+
"urls":['https://d.pslot.io/cQY2f', 'https://d.pslot.io/DbM3E'],
153+
"headers":{ "authorization": "Bearer <token>" }
154+
};
155+
Passbook.downloadPasses(callData, onSuccess, onError);
104156
```
105157

106158
## Passbook.addPass
107159

108160
Add a pass from a the provided local file and shows it to the user.
109161
When the pass was successfully shown to the user, and the user either canceled or added the pass, the `passCallback` callback executes. If there is an error, the `errorCallback` callback executes with an error string as the parameter
162+
```javascript
163+
Passbook.addPass(file, [passCallback], [errorCallback]);
164+
```
165+
### Parameters
166+
167+
- __file__: The file of the pass that should be shown. (e.g. file:///..../sample.pkpass)
168+
169+
- __passCallback__: (Optional) The callback that executes when the pass is shown to the user. Returns the local pass (passTypeIdentifier, serialNumber, passURL) and if it was added to Passbook.
170+
171+
- __errorCallback__: (Optional) The callback that executes if an error occurs, e.g if Passbook is not available, the URL is invalid or no valid pass was found at the given URL.
110172

111-
Passbook.addPass(file,
112-
[passCallback],
113-
[errorCallback]);
114173

174+
### Example
175+
```javascript
176+
// onSuccess Callback
177+
function onSuccess(pass, added) {
178+
console.log('Pass shown to the user');
179+
console.log(pass, added);
180+
}
181+
182+
// onError Callback receives a string with the error message
183+
//
184+
function onError(error) {
185+
alert('Could now show pass: ' + error);
186+
}
187+
188+
Passbook.addPass(cordova.file.applicationDirectory + 'sample.pkpass', onSuccess, onError);
189+
```
190+
## Passbook.addPasses
191+
192+
Add a list of passes from a the provided local files and shows it to the user.
193+
When the passes are successfully shown to the user, and the user either cancelled or added the passes, the `passCallback` callback executes. If there is an error, the `errorCallback` callback executes with an error string as the parameter
194+
```javascript
195+
Passbook.addPass(files, [passCallback], [errorCallback]);
196+
```
115197
### Parameters
116198

117-
- __file__: The file of the pass that should be downloaded. (e.g. file:///..../sample.pkpass)
199+
- __files__: The files of the passes that should be shown. (e.g. ["file:///..../sample1.pkpass","file:///..../sample2.pkpass"])
118200

119201
- __passCallback__: (Optional) The callback that executes when the pass is shown to the user. Returns the local pass (passTypeIdentifier, serialNumber, passURL) and if it was added to Passbook.
120202

121203
- __errorCallback__: (Optional) The callback that executes if an error occurs, e.g if Passbook is not available, the URL is invalid or no valid pass was found at the given URL.
122204

123205

124206
### Example
207+
```javascript
208+
// onSuccess Callback
209+
function onSuccess(passes, added) {
210+
console.log('Passes shown to the user');
211+
console.log(passes, added);
212+
}
125213

126-
// onSuccess Callback
127-
function onSuccess(pass, added) {
128-
console.log('Pass shown to the user');
129-
console.log(pass, added);
130-
}
131-
132-
// onError Callback receives a string with the error message
133-
//
134-
function onError(error) {
135-
alert('Could now show pass: ' + error);
136-
}
214+
// onError Callback receives a string with the error message
215+
//
216+
function onError(error) {
217+
alert('Could now show pass: ' + error);
218+
}
137219

138-
Passbook.addPass(cordova.file.applicationDirectory + 'sample.pkpass', onSuccess, onError);
220+
Passbook.addPasses(
221+
[
222+
cordova.file.applicationDirectory + 'sample1.pkpass',
223+
cordova.file.applicationDirectory + 'sample2.pkpass'
224+
],
225+
onSuccess,
226+
onError
227+
);
228+
```

0 commit comments

Comments
 (0)