fuse-open / fuselibs

Fuselibs is the Uno-libraries that provide the UI framework used in Fuse apps
https://npmjs.com/package/@fuse-open/fuselibs
MIT License
176 stars 72 forks source link

Introduce Platform Sign In #1366

Closed ichan-mb closed 3 years ago

ichan-mb commented 3 years ago

Platform SignIn is a SignIn mechanism that uses Sign In With Apple on iOS and Google SignIn on Android. There is two API added, PlatformSignIn as trigger action and FuseJS/Auth as javascript module.

This module does not provide UI elements of Platform Sign In. (Visual button of Sign In With Apple or Google Sign In Button). Users must design the Sign In Button itself that complies with design guidelines on both platform

For more information on what are the pre-request when implementing Sign In With Apple or Google Sign In, you can check the documentation on the Apple developer website or android developer website

For iOS, add "SystemCapabilities": { "SignInWithApple":true } in the unoproj file.

Example

The following example shows how to use it:

    <App>
        <JavaScript>
            var Auth = require('FuseJS/Auth');

            var signInHandler = function(result) {
                console.dir(result); 
                // result is json object containing these properties :
                // email -> user email that has been sign in / sign up
                // firstName -> User firstname
                // lastName -> User Lastname
                // userId -> User uniqe Id
            } 

            function doSignIn() {
                Auth.signIn().then(signInHandler);
            }

            Auth.hasSignedIn().then(function (result) {
                if (result) {
                    // user has already sign in
                }
            });

            module.exports = {
                doSignIn
            }

        </JavaScript>
        <StackPanel>
            <Button Text="Sign In">
                <Clicked>
                    <Callback Handler="{doSignIn}" />
                </Clicked>
            </Button>
            <Button Text="Sign In Using Trigger Action">
                <Clicked>
                    <PlatformSignIn Handler="{signInHandler}" />
                </Clicked>
            </Button>
        </StackPanel>
    </App

This PR contains:

mortend commented 3 years ago

https://travis-ci.org/github/fuse-open/fuselibs/builds/716044108