# react-native-apple-core

> Apple core for React Native

Latest version **1.1.0** (published 2020-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-apple-core
pnpm add react-native-apple-core
yarn add react-native-apple-core
bun add react-native-apple-core
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-01-13 |
| First published | 2019-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Thinnakrit |
| Maintainers | thinnakrit |
| Keywords | react-native, react-component, react-native-component, react, react native, mobile, ios, android, ui, apple, apple login, login, apple core, react-native-apple-core, react-native-apple-signin, apple signin |

## Links

- npm: https://www.npmjs.com/package/react-native-apple-core
- Repository: https://github.com/thinnakrit/react-native-apple-core
- Homepage: https://github.com/thinnakrit/react-native-apple-core#readme
- Issues: https://github.com/thinnakrit/react-native-apple-core/issues
- npm.io page: https://npm.io/package/react-native-apple-core

## Dependencies (7)

- [react](https://npm.io/package/react.md) 16.9.0
- [url-join](https://npm.io/package/url-join.md) ^4.0.1
- [jwt-decode](https://npm.io/package/jwt-decode.md) ^2.2.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [react-native](https://npm.io/package/react-native.md) 0.61.5
- [react-native-webview](https://npm.io/package/react-native-webview.md) ^8.0.3
- [react-native-raw-bottom-sheet](https://npm.io/package/react-native-raw-bottom-sheet.md) ^2.0.6

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-01-13
- 1.0.31 — 2020-01-02
- 1.0.30 — 2020-01-02
- 1.0.29 — 2020-01-02
- 1.0.28 — 2019-12-27
- 1.0.27 — 2019-12-12
- 1.0.26 — 2019-12-12
- 1.0.25 — 2019-12-12
- 1.0.24 — 2019-12-12
- 1.0.23 — 2019-12-12
- 1.0.22 — 2019-12-12
- 1.0.21 — 2019-12-12
- 1.0.20 — 2019-12-12
- 1.0.19 — 2019-12-12
- 1.0.18 — 2019-12-12
- … 18 more at https://npm.io/package/react-native-apple-core/versions

## README

# React Native Apple Core

Use Apple services on React Native

Update Log
- 1.1.0 : Update version react-native-webview@8.0.3

* Apple Sign in service [ iOS , Android ]
 
 

|                    iOS Native Apple Signin                                                   |Android Web Signin
| :--------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: |
| <img src="https://i.imgur.com/TXmhDAR.png" style="width: 300px;" /> | <img src="https://i.imgur.com/OcUvwpW.png" style="width: 300px;" /> |

# Install
Npm
```npm
npm install react-native-apple-core
```
Yarn
```yarn
yarn add react-native-apple-core
```

# Usage (1)  version >= 1.0.30

### Apple Sign in

```javascript
import { Text } from 'react-native'
import { AppleSignIn }  from 'react-native-apple-core'
// dom
<AppleSignIn
  ref={ ref => this.signinRef = ref}
  initialConfig={{
    redirect_uri: "https://www.example.app/apple-callback",
    client_id: "web.app.exampleapp",
    state: "xxkxkxkkxkxxkxk", // for compare response data
  }}
  onSuccess={ (result) => console.log('onSuccess', result) }
>
  <Text>Continue with Apple</Text>
</AppleSignIn>
```

#### Example
```jsx
import React, { Component } from 'react'
import { View, Text } from 'react-native'
import { AppleSignIn }  from 'react-native-apple-core'
class Sample extends Component {

  handleSuccess = (result) => {
    console.log('handleSuccess', result)
  }

  render() {
    return (
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <AppleSignIn
          ref={ ref => this.signinRef = ref}
          initialConfig={{
            redirect_uri: "https://www.example.app/apple-callback",
            client_id: "web.app.exampleapp",
            state: "xxkxkxkkxkxxkxk", // for compare response data
          }}
          onSuccess={ this.handleSuccess }
        >
          <Text>Continue with Apple</Text>
        </AppleSignIn>
      </View>
    )
  }
}

export default Sample
```


# Usage (2) version <= 1.0.30

### Apple Sign in

```javascript
import { AppleSignIn }  from 'react-native-apple-core'

// open popup
this.signinRef.openSignIn()

// dom
<AppleSignIn
  ref={ ref => this.signinRef = ref}
  initialConfig={{
    redirect_uri: "https://www.example.app/apple-callback",
    client_id: "web.app.exampleapp",
    state: "xxkxkxkkxkxxkxk", // for compare response data
  }}
  onSuccess={ (result) => console.log('onSuccess', result) }
/>
```

#### Example
```jsx
import React, { Component } from 'react'
import { View, TouchableOpacity, Image } from 'react-native'
import { AppleSignIn }  from 'react-native-apple-core'
class Sample extends Component {

  handleOpenSignIn = () => {
    this.signinRef.openSignIn()
  }

  handleSuccess = (result) => {
    console.log('handleSuccess', result)
  }

  render() {
    return (
      <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <TouchableOpacity onPress={this.handleOpenSignIn}>
          <Image
            style={{
              height: 40,
              width: 200,
              borderRadius: 5,
            }}
          source={{uri: "https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/images/apple-id-sign-in-with_2x.png"}} />
        </TouchableOpacity>
        <AppleSignIn
          ref={ ref => this.signinRef = ref}
          initialConfig={{
            redirect_uri: "https://www.example.app/apple-callback",
            client_id: "web.app.exampleapp",
            state: "xxkxkxkkxkxxkxk", // for compare response data
          }}
          onSuccess={ this.handleSuccess }
        />
      </View>
    )
  }
}

export default Sample
```

# Method
| Method Name | Type        | Description        |
| ----------- | ------------------ |------------------ |
| onSuccess       | Function | response data from apple service after login success. |

response 
```json
{
  "code": "xxxxxx",
  "id_token": "xxxxxxx",
  "state": "xxkxkxkkxkxxkxk",
  "data": {
    // jwt data
    "aud": "xxxx",
    "auth_time": "xxxx",
    "email": "xxxx",
    "sub": "xxxx",
  }
}

```

# Props
initialConfig : Object
<br />
For configulation apple service api.
Read more: <a href="https://developer.apple.com/documentation/signinwithapplejs/incorporating_sign_in_with_apple_into_other_platforms">https://developer.apple.com/documentation/signinwithapplejs/incorporating_sign_in_with_apple_into_other_platforms</a>

| Key Name        | Type   | Description                  |
| --------------- | ------ |----------------------------  |
| redirect_uri    | String | https://example.com/callback |
| client_id       | String | web.app.exampleapp           |
| state           | String | Generate for compare callback|

# License
MIT

# Author

Made with ❤️ by [Thinnakrit](https://github.com/thinnakrit).

---
_Source: https://npm.io/package/react-native-apple-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
