Socket
Book a DemoInstallSign in
Socket

@nativescript/apple-sign-in

Package Overview
Dependencies
Maintainers
19
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nativescript/apple-sign-in

Sign In With Apple

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
56
166.67%
Maintainers
19
Weekly downloads
 
Created
Source

@nativescript/apple-sign-in

ns plugin add @nativescript/apple-sign-in

Requirements

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 the following (or append) to a file named app.entitlements.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.developer.applesignin</key>
	<array>
		<string>Default</string>
	</array>
</dict>
</plist>

Usage

API

isSupported

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 { SignIn } from "@nativescript/apple-sign-in";

const supported: boolean = SignIn.isSupported();

signInWithApple

Now 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 { SignIn, User } from "@nativescript/apple-sign-in";

signIn(
    {
        // by default you don't get these details, but if you provide these scopes you will (and the user will get to choose which ones are allowed)
        scopes: ["EMAIL", "FULLNAME"]
    })
    .then((result: User) => {
        console.log("Signed in, user: " + result);
        console.log("Signed in, familyName: " + result.fullName.familyName);
        // you can remember the user to check the sign in state later (see 'getSignInWithAppleState' below)
        this.user = result.user;
    })
    .catch(err => console.log("Error signing in: " + err));

getState

⚠️ This does not seem to work on a simulator!

If you want to know the current Sign In status of your user, you can pass the user (id) you acquired previously.

import { SignIn } from "@nativescript/apple-sign-in";

const user: string = "the id you got back from the signIn function";

SignIn.getState(user)
    .then(state => console.log("Sign in state: " + state))
    .catch(err => console.log("Error getting sign in state: " + err));

License

Apache License Version 2.0

Keywords

NativeScript

FAQs

Package last updated on 09 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts