Skip to content

Commit e410851

Browse files
author
Kadi Kraman
authored
Merge pull request #541 from FormidableLabs/chore/upgrade-example-app
Chore/upgrade example app
2 parents b28dd17 + f0cceb0 commit e410851

21 files changed

+600
-9082
lines changed

Example/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

Example/.flowconfig

Lines changed: 0 additions & 74 deletions
This file was deleted.

Example/App.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
import React, { useState, useCallback, useMemo } from 'react';
2-
import { UIManager, LayoutAnimation, Alert } from 'react-native';
2+
import { UIManager, Alert } from 'react-native';
33
import { authorize, refresh, revoke, prefetchConfiguration } from 'react-native-app-auth';
44
import { Page, Button, ButtonContainer, Form, FormLabel, FormValue, Heading } from './components';
55

6-
UIManager.setLayoutAnimationEnabledExperimental &&
7-
UIManager.setLayoutAnimationEnabledExperimental(true);
8-
9-
type State = {
10-
hasLoggedInOnce: boolean,
11-
provider: ?string,
12-
accessToken: ?string,
13-
accessTokenExpirationDate: ?string,
14-
refreshToken: ?string
15-
};
166

177
const configs = {
188
identityserver: {
199
issuer: 'https://demo.identityserver.io',
20-
clientId: 'native.code',
10+
clientId: 'interactive.public',
2111
redirectUrl: 'io.identityserver.demo:/oauthredirect',
2212
additionalParameters: {},
2313
scopes: ['openid', 'profile', 'email', 'offline_access'],
@@ -52,7 +42,7 @@ const defaultAuthState = {
5242
refreshToken: ''
5343
};
5444

55-
export default () => {
45+
const App = () => {
5646
const [authState, setAuthState] = useState(defaultAuthState);
5747
React.useEffect(() => {
5848
prefetchConfiguration({
@@ -168,3 +158,5 @@ export default () => {
168158
</Page>
169159
);
170160
}
161+
162+
export default App;

Example/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
# React Native App Auth Example
22

33
![Demo](demo.gif)
4+
5+
## Running the iOS app
6+
7+
After cloning the repository, run the following:
8+
9+
```sh
10+
cd react-native-app-auth/Example
11+
yarn
12+
(cd ios && pod install)
13+
npx react-native run-ios
14+
```
15+
16+
## Running the Android app
17+
18+
After cloning the repository, run the following:
19+
20+
```sh
21+
cd react-native-app-auth/Example
22+
yarn
23+
npx react-native run-android
24+
```
25+
26+
Note that you have to have the emulator open before running the last command. If you have difficulty getting the emulator to connect, open the project from Android Studio and run it through there.

Example/android/app/build.gradle

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.android.build.OutputFile
2020
* // default. Can be overridden with ENTRY_FILE environment variable.
2121
* entryFile: "index.android.js",
2222
*
23-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2424
* bundleCommand: "ram-bundle",
2525
*
2626
* // whether to bundle JS and assets in debug mode
@@ -160,20 +160,13 @@ android {
160160
}
161161
release {
162162
// Caution! In production, you need to generate your own keystore file.
163-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
163+
// see https://reactnative.dev/docs/signed-apk-android.
164164
signingConfig signingConfigs.debug
165165
minifyEnabled enableProguardInReleaseBuilds
166166
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
167167
}
168168
}
169169

170-
packagingOptions {
171-
pickFirst "lib/armeabi-v7a/libc++_shared.so"
172-
pickFirst "lib/arm64-v8a/libc++_shared.so"
173-
pickFirst "lib/x86/libc++_shared.so"
174-
pickFirst "lib/x86_64/libc++_shared.so"
175-
}
176-
177170
// applicationVariants are e.g. debug, release
178171
applicationVariants.all { variant ->
179172
variant.outputs.each { output ->
@@ -203,6 +196,7 @@ dependencies {
203196

204197
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
205198
exclude group:'com.facebook.flipper'
199+
exclude group:'com.squareup.okhttp3', module:'okhttp'
206200
}
207201

208202
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {

Example/android/build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "28.0.3"
5+
buildToolsVersion = "29.0.2"
66
minSdkVersion = 16
7-
compileSdkVersion = 28
8-
targetSdkVersion = 28
7+
compileSdkVersion = 29
8+
targetSdkVersion = 29
99
}
1010
repositories {
1111
google()
1212
jcenter()
1313
}
1414
dependencies {
15-
classpath("com.android.tools.build:gradle:3.5.2")
16-
15+
classpath("com.android.tools.build:gradle:3.5.3")
1716
// NOTE: Do not place your application dependencies here; they belong
1817
// in the individual module build.gradle files
1918
}

Example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ android.useAndroidX=true
2525
android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
28-
FLIPPER_VERSION=0.33.1
28+
FLIPPER_VERSION=0.37.0
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

Example/android/gradlew

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
154154
else
155155
eval `echo args$i`="\"$arg\""
156156
fi
157-
i=$((i+1))
157+
i=`expr $i + 1`
158158
done
159159
case $i in
160-
(0) set -- ;;
161-
(1) set -- "$args0" ;;
162-
(2) set -- "$args0" "$args1" ;;
163-
(3) set -- "$args0" "$args1" "$args2" ;;
164-
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165-
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166-
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167-
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168-
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169-
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
160+
0) set -- ;;
161+
1) set -- "$args0" ;;
162+
2) set -- "$args0" "$args1" ;;
163+
3) set -- "$args0" "$args1" "$args2" ;;
164+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170170
esac
171171
fi
172172

@@ -175,14 +175,9 @@ save () {
175175
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176176
echo " "
177177
}
178-
APP_ARGS=$(save "$@")
178+
APP_ARGS=`save "$@"`
179179

180180
# Collect all arguments for the java command, following the shell quoting and substitution rules
181181
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182182

183-
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184-
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185-
cd "$(dirname "$0")"
186-
fi
187-
188183
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)