Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web+template): convert from fixed app to template, make it work on web #3

Merged
merged 13 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintrc.js

This file was deleted.

3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

62 changes: 2 additions & 60 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,60 +1,2 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
release.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
template/yarn.lock
template/ios/Podfile.lock
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .watchmanconfig

This file was deleted.

60 changes: 34 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,70 @@

Thank you for trying the Firebase Authentication example 👏

![How-its-going](/docs/assets/hero.png)

![See-it-in-action](/docs/assets/RNFBAuthDemo.gif)


**Please note that limited support is offered for this example though we will happily accept PRs.**

The following authentication features are ready for use in this example:

- Sign In
- Sign Out
- Create account
- Forgot Password
- Sign in with social auth providers
- Sign in with phone auth (with country selection)
- Linking social profiles
- Change Password
- Email verification
- Updating user profile
- Sign In
- Sign Out
- Create account
- Forgot Password
- Sign in with social auth providers
- Sign in with phone auth (with country selection)
- Linking social profiles
- Change Password
- Email verification
- Updating user profile

and the following providers:

- Email / Password Sign In
- Facebook
- Google
- Phone Auth via SMS
- Email / Password Sign In
- Phone Auth via SMS
- Apple (Native, iOS only, PRs needed for web support)
- Facebook (Native only, PRs needed for web support)
- Google (Native only, PRs needed for web support)

This template creates an app that comes out of the box ready with [typescript](https://www.typescriptlang.org/) and [react-native-web](https://necolas.github.io/react-native-web/) support, based on [the Luna template](https://github.com/plaut-ro/luna#readme)

## Getting started

Ensure your development environment is set up for React Native by following the [React Native documentation](https://reactnative.dev/docs/environment-setup).

### Install dependencies
### Create an app using the template

1. Install [NPM](https://www.npmjs.com) dependencies with [Yarn](https://yarnpkg.com/lang/en/): `yarn`.
2. Install [CocoaPods](https://cocoapods.org) inside of the `ios` directory: `npx pod-install`
1. For a quick demonstration, this template is pre-configured with a firebase project called `ProjectName`, if you just want to see it work, run `npx react-native init ProjectName --template invertase/react-native-firebase-authentication-example
1. For a real project, replace `ProjectName` in the init command with your new project's real name, then follow the configuration instructions below

### Android: Setting up App Signing

Google Sign-In requires a `keystore` file to be added to your project and the Firebase console for both debug and release builds, we've included a `debug` one by default. To setup a new `keystore` file, follow the [guide here](https://developer.android.com/studio/publish/app-signing#debug-mode).

### Add your app id and name

This project is preconfigured with `market.reactnative.firebaseauthkit` as its app id. You will probably want to replace it using the `rename-script` npm script provided with this product.

### Add your Firebase credentials

1. Choose your existing Firebase project from the [Firebase console](https://console.firebase.google.com/).
> Creating a new project? Check out the React Native Firebase [documentation](https://rnfirebase.io/#prerequisites).
2. Add the Firebase credentials to your project by following documentation for [Android](https://rnfirebase.io/#generating-android-credentials) and [iOS](https://rnfirebase.io/#generating-ios-credentials).

**WARNING** The application will _not_ start until you copy your `GoogleServices-Info.plist` file into `./ios/FirebaseAuthenticationKit/` and your `google-services.json` into `./android/app/`. It will install and begin running but then crash immediately as those files are necessary for Firebase to start.
2. Replace the native Firebase credentials template files to your project by following documentation for [Android](https://rnfirebase.io/#generating-android-credentials) and [iOS](https://rnfirebase.io/#generating-ios-credentials).
3. Copy the web config from Firebase console into `src/shims/firebase-init.ts`

### Run the app

- Start the metro javascript bundler: `yarn start`
- For android: `yarn android`
- For iOS: `yarn ios`
- For apple: `yarn ios`
- For web: `yarn web`
- For testing (jest): `yarn test:all`
- For linting (format, lint, typescript): `yarn lint:all`

## Authentication Providers

The Firebase Authentication Example supports multiple authentication providers. Follow the links below for documentation on setting up each provider:
The Firebase Authentication Example supports multiple authentication providers.

Follow the links below for documentation on setting up each provider:

- [Apple Authentication](/docs/apple.md)
- [Email and Password Authentication](/docs/email-password-auth.md)
Expand Down
Binary file removed android/app/debug.keystore
Binary file not shown.
46 changes: 0 additions & 46 deletions android/app/src/main/AndroidManifest.xml

This file was deleted.

Binary file removed android/app/src/main/assets/fonts/Feather.ttf
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/Ionicons.ttf
Binary file not shown.
Binary file not shown.
Binary file removed android/app/src/main/assets/fonts/MaterialIcons.ttf
Binary file not shown.

This file was deleted.

7 changes: 0 additions & 7 deletions android/app/src/main/res/values/strings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions android/keystores/BUCK

This file was deleted.

4 changes: 0 additions & 4 deletions android/keystores/debug.keystore.properties

This file was deleted.

3 changes: 0 additions & 3 deletions android/settings.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions app.json

This file was deleted.

4 changes: 0 additions & 4 deletions babel.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions config.json

This file was deleted.

2 changes: 1 addition & 1 deletion docs/apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This project comes set up with [react-native-apple-authentication](https://github.com/invertase/react-native-apple-authentication) out of the box.
Please follow the instructions on react-native-apple-authentication's [README.md](https://github.com/invertase/react-native-apple-authentication/blob/main/README.md) which you need to follow carefully before enabling apple authentication.

Please note, Apple authentication is only available on iOS.
Please note, Apple authentication is currently only available on native iOS platform.

## Firebase

Expand Down
Binary file added docs/assets/RNFBAuthDemo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions docs/facebook-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ allowing you to take full advantage of Facebook's native SDK. Example authentica

As with all third party authentication providers you will need to configure your project details to use Facebook's SDK.

Please note, Facebook authentication is currently only available on native platforms.

## Configuration

Before you begin you will need to create a developer account at [Facebook Developer Portal](https://developers.facebook.com) if you haven't done so already.
Expand All @@ -24,14 +26,14 @@ Once you have your developer account set up:

4. If you want to allow users to sign in via notifications enable single sign on.

5. You will be given code snippets to add to your [Info.plist](/ios/FirebaseAuthenticationKit/Info.plist) file. To add them:
5. You will be given code snippets to add to your [Info.plist](/template/ios/ProjectName/Info.plist) file. To add them:

1. Open your [.xcworkspace](ios/FirebaseAuthenticationKit.xcworkspace) project via XCode.
1. Open your [.xcworkspace](ios/ProjectName.xcworkspace) project via XCode.
2. Locate your `Info.plist` file and right click: `Open As` -> `Source Code`.
![xcode-plist](/docs/assets/xcode-info-plist.png)
3. Paste in your url type details snippet.
3. Replace the template default configuration in your url type details snippet.
![xcode-url-schema](/docs/assets/xcode-url-schema.png)
4. Any other Info.plist config snippets have already been pre-configured.
4. Any other Facebook Info.plist config snippets should be replaced with your new Facebook App Id and Client Token.
5. NOTE: You don't need to add `-ObjC` flag to your project as all React Native apps already include it.

6. The "Connect AppDelegate" step is not required as auth kit already includes it.
Expand All @@ -46,7 +48,7 @@ Once you have your developer account set up:

4. Generate development key hash (as instructed in **Facebook Developer Dashboard**).

5. Add the generated resources to your project, you only need to update [android/app/res/values/strings.xml](android/app/res/values/strings.xml) everything else is already included. You can perform global search for `<!-- [android] facebook_app_id -->` and `<!-- [android] fb_login_protocol_scheme -->` comments to find exact places where these details should be placed.
5. Add the generated resources, Facebook App ID and Client Token to your project, with an update to [android/app/res/values/strings.xml](template/android/app/res/values/strings.xml) and [android/app/src/main/AndroidManifest.xml](template/android/app/src/main/AndroidManifest.xml) everything else is already included.
![android strings](/docs/assets/android-strings.png)

6. The rest of the native implementation is already pre-configured.
Expand Down
8 changes: 5 additions & 3 deletions docs/google-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ allowing you to take full advantage of Google's native SDK. Example authenticati

As with all third party authentication providers you will need to configure your project details to use Google's SDK.

Please note, Google authentication is currently only available on native platforms.

## Configuration

This guide assumes that you have already created your Firebase app and configured your iOS and Android projects as explained in [README](README.md).

To begin, replace the webClientId in `config.json` (found in the root directory of the app) with your own, which is used by the app to call `GoogleSignin.configure`; and is needed whenever that method is called. This ID is automatically generated when you create your Firebase project and you can find it under "Web Application -> Client ID" in your [Google Cloud Console](https://console.developers.google.com/apis/credentials). Make sure you select right project.
To begin, replace the webClientId in `src/config.json` with your own, which is used by the app to call `GoogleSignin.configure`; and is needed whenever that method is called. This ID is automatically generated when you create your Firebase project and you can find it under "Web Application -> Client ID" in your [Google Cloud Console](https://console.developers.google.com/apis/credentials). Make sure you select right project.

### IOS

1. Open your project via XCode and navigate to your `GoogleService-Info.plist` file (normally located at `/ios/[YourApp]/Info.plist`). Copy your `REVERSED_CLIENT_ID` from this file.

2. You can add this code manually by globally searching for `<!-- [ios] GoogleURLScheme -->` comment. Alternatively, click on your xcode project icon (blue one) and under Info tab expand `URL Types` panel. Add new url type and under `URL Schema` paste your previously coppied `REVERSED_CLIENT_ID` field value. NOTE: you might see more entries here if you use other social auth providers like Facebook.
2. Alternatively, click on your xcode project icon (blue one) and under Info tab expand `URL Types` panel. Add new url type and under `URL Schema` paste your previously coppied `REVERSED_CLIENT_ID` field value. NOTE: you might see more entries here if you use other social auth providers like Facebook.
![google url type](/docs/assets/google-url-type.png)

3. Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart XCode.
3. Run your app and make sure that everything is working. If you run into any trouble it is worth trying to clean your caches and restart XCode (possibly via `npx react-native-clean-project`)

### Android

Expand Down
9 changes: 0 additions & 9 deletions index.js

This file was deleted.

Loading