Sign in with Apple, for NativeScript
My Linked https://www.linkedin.com/in/tungtranuit/
You can get the Infomations : User, Email, RealUserStatus, IdentityToken, AuthCode , fullName (givenName,familyName ,middleName, namePrefix,nameSuffix,nickname,phoneticRepresentation ) ...
{
user: user ,
email: email,
fullName:{
givenName
familyName
middleName
namePrefix
nameSuffix
nickname
phoneticRepresentation
},
realUserStatus: realUserStatus,
identityToken: identityToken,
authCode: authCode
}
Re-wirte Plugin from https://github.com/EddyVerbruggen/nativescript-apple-sign-in.
Go to the Apple developer website and create a new app identifier with the "Sign In with Apple" Capability enabled. Make sure you sign your app with a provisioning profile using that app identifier. Open your app's App_Resources/iOS folder and add this (or append) to a file named app.entitlements.
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
tns plugin add nativescript-ns-apple-signin
tns plugin add nativescript-ns-apple-signin
Sign In with Apple was added in iOS 13, so make sure to call this function before showing a "Sign In with Apple" button in your app.
On iOS < 13 and Android this will return false
.
import { isSignInWithAppleSupported } from "nativescript-ns-apple-signin";
const supported: boolean = isSignInWithAppleSupported();
Not that you know "Sign In with Apple" is supported on this device, you can have the user sign themself in (after they pressed a nice button for instance).
import { signInWithApple } from "nativescript-ns-apple-signin";
signInWithApple(
{
scopes: ["EMAIL","FULLNAME"]
})
.then(credential => {
console.log("Signed in, user: " + credential.user);
console.log("Signed in, user: " + credential.email);
console.log("Signed in, user: " + JSON.stringify(credential.fullName));
this.user = credential.user;
})
.catch(err => console.log("Error signing in: " + err));
If you want to know the current Sign In status of your user, you can pass the user
(id) you acquired previously.
import { getSignInWithAppleState } from "nativescript-apple-sign-in";
const user: string = "the id you got back from the signInWithApple function";
getSignInWithAppleState(user)
.then(state => console.log("Sign in state: " + state))
.catch(err => console.log("Error getting sign in state: " + err));
Apache License Version 2.0, January 2004