see also: Official Documentation
This plugin only supports iOS >= 13.
cordova plugin add cordova-plugin-sign-in-with-apple
or
cordova plugin add https://github.com/twogate/cordova-plugin-sign-in-with-apple.git
You should enable Sign in with Apple capability in Xcode. (project file -> Capabilities Tab -> Turn on "SignIn With Apple")
window.cordova.plugins.SignInWithApple.signin(
{ requestedScopes: [0, 1] },
function(succ){
console.log(succ)
alert(JSON.stringify(succ))
},
function(err){
console.error(err)
console.log(JSON.stringify(err))
}
)
requestedScopes
is an array of requested scopes.0
:FullName
1
:Email
Based on ASAuthorizationAppleIDCredential.
- authorizationCode: string
"<short-lived token used by your app for proof of authorization when interacting with the app’s server counterpart>"
- email: string
"address@example.com"
- fullName: object, based on NSPersonNameComponents
- familyName: string
"Doe"
- givenName: string
"Jane"
- namePrefix: string
""
- nameSuffix: string
""
- nickname: string
""
- phoneticRepresentation: object, based on NSPersonNameComponents
- familyName?: string
- givenName?: string
- namePrefix?: string
- nameSuffix?: string
- nickname?: string
- familyName: string
- identityToken: string
"<JSON Web Token (JWT) that securely communicates information about the user to your app>"
- state: string
"<arbitrary string that your app provided to the request that generated the credential>"
- user: string
"<identifier associated with the authenticated user>"
- error: string
"ASAUTHORIZATION_ERROR"
- code: string
1001
- localizedDescription: string
"The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.)"
- localizedFailureReason: string
""
1000
ASAuthorizationErrorUnknown
1001
ASAuthorizationErrorCanceled
1002
ASAuthorizationErrorInvalidResponse
1003
ASAuthorizationErrorNotHandled