GithubHelp home page GithubHelp logo

Comments (3)

Peter-ChengTszTung avatar Peter-ChengTszTung commented on July 19, 2024

cc @louischan-oursky
Notes for RN iOS:

Prerequisites

  • Enable Authgear OAuth Feature

Setup

  • Install @authgear/react-native and @react-native-community/async-storage packages

    yarn add @authgear/react-native -S
    yarn add @react-native-community/async-storage -S
    
    cd ios
    pod install
    
  • Add a URL scheme to your iOS project (iOS 10 or below)

    • Open ios/{project}.xcworkspace
    • Under {project} -> {target} -> info tab -> URL types section
    • Press '+' button
    • TBC
  • Setup UIApplicationDelegate with AGAuthgearReactNative bridge

    • Open ios/{project}.xcworkspace
    • Under AppDelegate.m, add
      ...
      #import <authgear-react-native/AGAuthgearReactNative.h>
      ...
      - (BOOL)application:(UIApplication *)app
                  openURL:(NSURL *)url
                  options:
                      (NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
          return [AGAuthgearReactNative application:app openURL:url options:options];
      }
      
      - (BOOL)application:(UIApplication *)application
                    openURL:(NSURL *)url
          sourceApplication:(NSString *)sourceApplication
                annotation:(id)annotation {
          return [AGAuthgearReactNative application:application
                                            openURL:url
                                  sourceApplication:sourceApplication
                                        annotation:annotation];
      }
      
      - (BOOL)application:(UIApplication *)application
          continueUserActivity:(NSUserActivity *)userActivity
            restorationHandler:
                (void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))
                    restorationHandler {
          return [AGAuthgearReactNative application:application
                              continueUserActivity:userActivity
                                restorationHandler:restorationHandler];
      }

Get Started

const container = new ReactNativeContainer();
container.configure({
  clientID: '{client_id}',
  endpoint: 'https://localhost:3000',
});

const authorizeOptions = {
  redirectURI: {redirect_uri}
};

const authResponse = await container.authorize(authorizeOptions);
console.log(authResponse.userInfo);

from docs.

Peter-ChengTszTung avatar Peter-ChengTszTung commented on July 19, 2024

@louischan-oursky
Notes:

  • iOS 11 or above: No need to setup URL scheme and app delegate

  • iOS 10: application:openURL:options: and application:continueUserActivity:restorationHandler:

  • iOS 9: application:openURL:sourceApplication:annotation: and application:continueUserActivity:restorationHandler:

  • React native 0.63 drop iOS 9 support

from docs.

louischan-oursky avatar louischan-oursky commented on July 19, 2024

iOS 11 or above: No need to setup URL scheme and app delegate

Any details?

from docs.

Related Issues (20)

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.