You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-9Lines changed: 32 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# com.passslot.cordova.plugin.passbook
1
+
# cordova-plugin-passbook
2
2
3
3
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))
4
4
@@ -14,9 +14,7 @@ Or the latest (unstable) version:
14
14
15
15
## Supported Platforms
16
16
17
-
18
17
- iOS
19
-
-~~Android~~ (coming soon)
20
18
21
19
## Example
22
20
@@ -25,9 +23,7 @@ Or the latest (unstable) version:
25
23
```javascript
26
24
Passbook.downloadPass('https://d.pslot.io/cQY2f', function (pass, added) {
27
25
console.log(pass, added);
28
-
if (added) {
29
-
Passbook.openPass(pass);
30
-
} else {
26
+
if (!added) {
31
27
alert('Please add the pass');
32
28
}
33
29
}, function (error) {
@@ -46,16 +42,43 @@ Or the latest (unstable) version:
46
42
47
43
Passbook.downloadPass(callData, function (pass, added) {
48
44
console.log(pass, added);
49
-
if (added) {
50
-
Passbook.openPass(pass);
51
-
} else {
45
+
if (!added) {
52
46
alert('Please add the pass');
53
47
}
54
48
}, function (error) {
55
49
console.error(error);
56
50
});
57
51
```
58
52
53
+
### Multiple passes
54
+
55
+
```javascript
56
+
Passbook.downloadPasses(['https://d.pslot.io/cQY2f', 'https://d.pslot.io/AeY3D'], function (passes, added) {
@@ -31,26 +31,25 @@ Returns if Passbook is available on the current device to the `resultCallback` c
31
31
32
32
33
33
### Example
34
+
```javascript
35
+
// onSuccess Callback
36
+
// This method accepts a boolean, which specified if Passbook is available
37
+
//
38
+
varonResult=function(isAvailable) {
39
+
if(!isAvailable) {
40
+
alert('Passbook is not available');
41
+
}
42
+
};
34
43
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
+
```
46
46
## Passbook.downloadPass
47
47
48
48
Downloads a pass from a the provided URL and shows it to the user.
49
49
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
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
-__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
+
functiononSuccess(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
Add a pass from a the provided local file and shows it to the user.
109
161
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
-__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.
110
172
111
-
Passbook.addPass(file,
112
-
[passCallback],
113
-
[errorCallback]);
114
173
174
+
### Example
175
+
```javascript
176
+
// onSuccess Callback
177
+
functiononSuccess(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
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
-__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"])
118
200
119
201
-__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.
120
202
121
203
-__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.
122
204
123
205
124
206
### Example
207
+
```javascript
208
+
// onSuccess Callback
209
+
functiononSuccess(passes, added) {
210
+
console.log('Passes shown to the user');
211
+
console.log(passes, added);
212
+
}
125
213
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
0 commit comments