1
1
import { Injectable } from '@angular/core' ;
2
2
import { Plugin , Cordova , IonicNativePlugin } from '@ionic-native/core' ;
3
3
4
+ /**
5
+ * @see https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidrequest
6
+ */
7
+ export class ASAuthorizationAppleIDRequest {
8
+ static readonly ASAuthorizationScopeFullName = 0 ;
9
+ static readonly ASAuthorizationScopeEmail = 1 ;
10
+
11
+ requestedScopes ?: number [ ] ;
12
+ }
13
+
4
14
/**
5
15
* @see https://developer.apple.com/documentation/foundation/nspersonnamecomponents/1412193-phoneticrepresentation
6
16
*/
@@ -116,15 +126,20 @@ export interface AppleSignInErrorResponse extends NSError {
116
126
*
117
127
* @usage
118
128
* ```typescript
119
- * import { SignInWithApple, AppleSignInResponse, AppleSignInErrorResponse } from '@ionic-native/sign-in-with-apple/ngx';
129
+ * import { SignInWithApple, AppleSignInResponse, AppleSignInErrorResponse, ASAuthorizationAppleIDRequest } from '@ionic-native/sign-in-with-apple/ngx';
120
130
*
121
131
*
122
132
* constructor(private signInWithApple: SignInWithApple) { }
123
133
*
124
134
* ...
125
135
*
126
136
*
127
- * this.signInWithApple.signin()
137
+ * this.signInWithApple.signin({
138
+ * requestedScopes: [
139
+ * ASAuthorizationAppleIDRequest.ASAuthorizationScopeFullName,
140
+ * ASAuthorizationAppleIDRequest.ASAuthorizationScopeEmail
141
+ * ]
142
+ * })
128
143
* .then((res: AppleSignInResponse) => {
129
144
* // https://developer.apple.com/documentation/signinwithapplerestapi/verifying_a_user
130
145
* alert('Send token to apple for verification: ' + res.identityToken);
@@ -151,11 +166,11 @@ export class SignInWithApple extends IonicNativePlugin {
151
166
* Starts the authorization flows named during controller initialization
152
167
* @see https://developer.apple.com/documentation/authenticationservices/asauthorizationcontroller/3153047-performrequests
153
168
* @return {Promise<AppleSignInResponse> } Returns a promise when authorization succeeds
154
- * @param arg0
169
+ * @param { ASAuthorizationAppleIDRequest } options
155
170
* @throws AppleSignInErrorResponse
156
171
*/
157
172
@Cordova ( )
158
- signin ( arg0 : object = null ) : Promise < AppleSignInResponse > {
173
+ signin ( options : ASAuthorizationAppleIDRequest = { } ) : Promise < AppleSignInResponse > {
159
174
return ;
160
175
}
161
176
0 commit comments