Git Product home page Git Product logo

react-native-apple-authentication's Introduction

react-native-apple-authentication

This npm module is used for authentication using Apple id in React Native apps. Apple sign-in only works with IOS platform and the setup guide considers the same.

Getting Started

To install the module, run the following command in your project directory:

$ npm install --save react-native-apple-authentication

Automatic Installation

From react-native version 0.60 we don't need to link any third party module separately but if you found it has not been included with your project then you can run the following:

$ react-native link react-native-apple-authentication

Manual Installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-apple-authentication and add AppleSignIn.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libAppleSignIn.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

Configure Project

iOS

  1. Sign in with Apple is supportable from XCode 11 and iOS 13. Although you can install XCode 11 on Mac Mojave 10.14.14 and later.
  2. Before running the project set development team in the Signing & Capabilities tab so Xcode can create a provisioning profile that. If you've already created project and provisioning profile then ignore this.
  3. Add the Sign In with Apple capability in your project. This will add an entitlement that lets your app use Sign In with Apple.
  4. When you try to sign in, you'll see an AUTH_ALERT_SIGN_UP_NOT_COMPLETED error message. Signing in won't work in your application until you create a key with Sign in with Apple enabled in your developer account.
  5. To enable Sign In with Apple in your developer account you need to create an Auth Key with Sign In with Apple. on your developer account.
  6. If you don’t see the Sign in with Apple listed when you create a key the you're probably in an Enterprise team. Just creating the key should sufficent for now, you will only need to download it when you want to support Sign in with Apple from somewhere other than your application.
  7. If you're creating a key for grouped app then create a key for your primary App ID in order to implement Sign In with Apple. This key will also be used for any App IDs grouped with the primary. The user will see your primary app's icon at sign in and in their Apple ID account settings.
  8. Test this on real iPhone device

Props

Prop Value
buttonText Optional
buttonStyle Optional
textStyle Optional

Functions

Function Value
callBack Required

Usage

import { SignInWithAppleButton } from 'react-native-apple-authentication'
export default class App extends React.Component{

  render(){
    return(
    <View style = {styles.container}>
     {SignInWithAppleButton({
          buttonStyle: styles.appleBtn, 
          callBack: this.appleSignIn,
          buttonText: "Sign Up With Apple",
        })}
    </View>)

  }

  appleSignIn = (result) => {
    console.log('Resssult',result);
  };

}


const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'white',
  },
  appleBtn: { height: 44, width: 200 }
});

LICENSE

MIT

react-native-apple-authentication's People

Contributors

akhilesh-systango avatar amourya-systango avatar dependabot[bot] avatar khuongphp avatar thehanimo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-apple-authentication's Issues

identityToken is null

Hi there ! It seems like the login button works, but in the callback the identityToken is never returned, which I need to validate the user server side. The user id and the email are correctly returned.

apple login return null data

when we do apple login it return null object. Please help me to resolve this issues.
Result:
{"authorizationCode": null, "authorizedScopes": [], "email": null, "fullName": null, "identityToken": null, "realUserStatus": 1, "state": null, "user": "001810.9b25b516428f41a5920c6b46b6697674.1051"}
how we get email,fullName in this mehtod.

Empty callback After Login

Once the Login is done, the returned payload is mostly empty:

{"authorizationCode": null, "authorizedScopes": [], "email": null, "firstName": null, "identityToken": null, "lastName": null, "realUserStatus": 1, "state": null, "user": "000466...."}

Error when click to sigin with Apple

I have the error when click to Sign in with Apple

Possible Unhandled Promise Rejection (id: 0):
TypeError: null is not an object (evaluating 'AppleAuthentication.requestAsync')

AppleAuthentication is null.
Could you please help?

[iOS] I got an error "Apple sign in only support iOS 13 or newer"

Screenshot_2

As in this description 1. Sign in with Apple is supportable from XCode 11 and iOS 13. Although you can install XCode 11 on Mac Mojave 10.14.14 and later.
I think we need some check in this function like this


-(NSDictionary *)constantsToExport
{
    if (@available(iOS 13.0, *)) { // <=== add this
        NSDictionary* scopes = @{@"FULL_NAME": ASAuthorizationScopeFullName, @"EMAIL": ASAuthorizationScopeEmail};
        NSDictionary* operations = @{
            @"LOGIN": ASAuthorizationOperationLogin,
            @"REFRESH": ASAuthorizationOperationRefresh,
            @"LOGOUT": ASAuthorizationOperationLogout,
            @"IMPLICIT": ASAuthorizationOperationImplicit
        };
        NSDictionary* credentialStates = @{
            @"AUTHORIZED": @(ASAuthorizationAppleIDProviderCredentialAuthorized),
            @"REVOKED": @(ASAuthorizationAppleIDProviderCredentialRevoked),
            @"NOT_FOUND": @(ASAuthorizationAppleIDProviderCredentialNotFound),
        };
        NSDictionary* userDetectionStatuses = @{
            @"LIKELY_REAL": @(ASUserDetectionStatusLikelyReal),
            @"UNKNOWN": @(ASUserDetectionStatusUnknown),
            @"UNSUPPORTED": @(ASUserDetectionStatusUnsupported),
        };
        
        return @{
            @"Scope": scopes,
            @"Operation": operations,
            @"CredentialState": credentialStates,
            @"UserDetectionStatus": userDetectionStatuses
        };
    } else {// <== previous version
        // Fallback on earlier versions
        return @{};
    }
}

How to implement buttonText

Hello i want to change the text from Sign in with apple to Sign Up with apple, because i get issues from apple review in my register page.

I already try like this but the button was gone :

{SignInWithAppleButton({
	buttonText: "Sign Up With Apple",
	buttonStyle: styles.appleBtn,
	callBack: this.appleSignIn,
})}

please help my deadline was 4 days again for up to app store :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.