capacitor-plugin-sign-in-with-apple
v0.0.5
Published
one sign in with apple plugin
Downloads
9
Readme
Required
* mac 10.15 .0 or above
* os13 or above
* enables `Sign in with Apple` features on Apple developer website
* Signing & Capabilities in Xcode enables `Sign in with Apple`
Installation
npm i capacitor-plugin-sign-in-with-apple
Usage
import {
Plugins,
Capacitor
} from '@capacitor/core';
const {
SignInWithApple
} = Plugins;
get isiOS(): boolean {
return Capacitor.getPlatform() === 'ios';
}
/* then:
success: {"state" : 1, info: {state:xx,userIdentifier:xx,familyName:xx,givenName:xnickname:xxmiddleName:xx,namePrefix:xx,email:xx,identityToken:xx,authCode:xx....}}
error: {"state" : -1
"errCode" : errCode,
"errDesc" : errDesc
}
errCode = 0 , errDesc: other
errCode = -1 , errDesc: User cancelled authorization request
errCode = -2 , errDesc: Authorization request failed
errCode = -3 , errDesc: Authorization request is not responding
errCode = -4 , errDesc: Failed to process authorization request
errCode = -5 , errDesc: Authorization request failed : unknown reason
*/
login(): Promise <any> | null {
if (!this.isiOS) return null;
if (!SignInWithApple) return null;
return SignInWithApple.login()
}
/**
* then: {canShowButton: true/false}
*/
getCanShowButton(): Promise <any> | null {
if (!this.isiOS) return null;
if (!SignInWithApple) return null;
return SignInWithApple.getCanShowButton()
}
/**
*
* @param userId string
* then:
* {"state":1,"errDesc": "Apple ID Credential is valid"}
{"state":-1, "errDesc": "Apple ID Credential revoked, handle unlink"}
{"state":-2, "errDesc": "Credential not found, show login UI"}
{"state":-3, "errDesc": "Other"}
*/
public checkState(userId: string): Promise <any> | null {
if (!this.isiOS) return null;
if (!SignInWithApple) return null;
let message = {
userId
}
return SignInWithApple.checkStateWithUserID(message)
}