Skip to content

Commit 00cb0f2

Browse files
committed
test: rebuild example app, split mainline from other platforms
this way we have one app that stays generally up to date (currently 0.82) while the other platforms which lag behind still exist but don't hold back mainline (they are currently 0.79)
1 parent 09e02b0 commit 00cb0f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+24818
-8760
lines changed

.github/workflows/tests_e2e.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ jobs:
110110
with:
111111
path: |
112112
example/ios/Pods
113-
example/macos/Pods
114-
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock', 'example/macos/Podfile.lock') }}
113+
example-other/macos/Pods
114+
example-other/visionos/Pods
115+
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock', 'example-other/macos/Podfile.lock', 'example-other/visionos/Podfile.lock') }}
115116

116117
# Detox is compiled during yarn install, using Xcode, set up cache first
117118
- uses: hendrikmuhs/ccache-action@v1
@@ -148,8 +149,10 @@ jobs:
148149
timeout_minutes: 10
149150
retry_wait_seconds: 60
150151
max_attempts: 3
151-
command: yarn && yarn example:prepare
152+
command: yarn && yarn example:prepare && yarn example:other:prepare
152153

153154
- name: Build iOS App
154155
run: |
155156
yarn example:build:ios
157+
yarn example:other:build:macos
158+
yarn example:other:build:visionos

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,4 +547,5 @@ Pods/*
547547

548548
.yarn/cache
549549
.yarn/install-state.gz
550-
example/.yarn
550+
example/.yarn
551+
example-other/.yarn

README.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The `@invertase/react-native-apple-authentication` library will not work if you
3232
- **Once you're sure you've met the above, please follow our [Initial development environment setup](docs/INITIAL_SETUP.md) guide.**
3333

3434
## Version 2.0.0 breaking changes
35+
3536
Version 2 added Android support and introduced a few breaking changes with how methods are accessed. Please see the [Migration Guide](docs/MIGRATION.md).
3637

3738
## Installation
@@ -47,6 +48,7 @@ You will not have to manually link this module as it supports React Native auto-
4748
### Expo usage
4849

4950
To enable the Sign In with Apple capability in your app, set the ios.usesAppleSignIn property to true in your project's app config:
51+
5052
```json
5153
{
5254
"expo": {
@@ -70,7 +72,6 @@ Below are simple steps to help you get up and running. The implementation differ
7072
- If you're authenticating users via `React Native Firebase`; see our [Firebase guide](docs/FIREBASE.md)
7173
- For Android support, a couple extra steps are required on your Apple developer account. Checkout [our guide](docs/ANDROID_EXTRA.md) for more info.
7274

73-
7475
### iOS
7576

7677
#### 1. Initial set-up
@@ -106,6 +107,7 @@ function App() {
106107
```
107108

108109
#### 2. Implement the login process
110+
109111
```js
110112
// App.js
111113

@@ -166,7 +168,9 @@ So it is recommended when logging out to just clear all data you have from a use
166168
### Android
167169

168170
#### 1. Initial set-up
171+
169172
Make sure to correctly configure your Apple developer account to allow for proper authentication on Android. You can checkout [our guide](docs/ANDROID_EXTRA.md) for more info.
173+
170174
```js
171175
// App.js
172176

@@ -194,6 +198,7 @@ function App() {
194198
```
195199

196200
#### 2. Implement the login process
201+
197202
```js
198203
// App.js
199204

@@ -235,19 +240,19 @@ async function onAppleButtonPress() {
235240
}
236241
```
237242

238-
239243
### MacOS
240244

241245
This library works on MacOS 10.15+ if using in conjunction with [react-native-macos](https://github.com/microsoft/react-native-macos).
242246

243-
244247
### Web (not react-native-web, but that may come as a follow-on, this is pure web at the moment)
245248

246249
#### 1. Initial set-up
250+
247251
- Ensure you follow the android steps above.
248252
- Install the [web counterpart](https://github.com/A-Tokyo/react-apple-signin-auth) `yarn add react-apple-signin-auth` in your web project.
249253

250254
#### 2. Implement the login process on web
255+
251256
```js
252257
import AppleSignin from 'react-apple-signin-auth';
253258

@@ -289,6 +294,7 @@ export default MyAppleSigninButton;
289294
```
290295

291296
#### 3. Verify serverside
297+
292298
- Send the apple response to your server.
293299
- See [Serverside Verification](#serverside-verification)
294300
- Ensure that you pass the clientID as the web service ID, not the native app bundle. Since the project utilizes the service ID for authenticating web and android.
@@ -299,10 +305,13 @@ export default MyAppleSigninButton;
299305

300306
- Based on the [Firebase implementation guidelines](https://firebase.google.com/docs/auth/ios/apple#sign_in_with_apple_and_authenticate_with_firebase) the nonce provided to `appleAuth.performRequest` (iOS) and `appleAuthAndroid.configure` (Android) is automatically SHA256-hashed.
301307
- To verify the nonce serverside you first need to hash the nonce value, ie:
308+
302309
```js
303310
crypto.createHash('sha256').update(nonce).digest('hex');
304311
```
312+
305313
- The nonce can then be easily compared serverside for extra security verification, ie:
314+
306315
```js
307316
import crypto from 'crypto';
308317
import appleSigninAuth from 'apple-signin-auth';
@@ -322,28 +331,35 @@ All API documentation is generated by typedoc, and [is available in the `typedoc
322331
1. Why does `full name` and `email` return `null`?
323332
- Apple only returns the `full name` and `email` on the first login, it will return `null` on the succeeding login so you need to save those data.
324333
- Apple APIs [appear to be sensitive to the order you place the scopes in the auth request](https://github.com/invertase/react-native-apple-authentication/issues/293). Place first name *first*, like this:
334+
325335
```javascript
326336
const appleAuthRequestResponse = await appleAuth.performRequest({
327337
requestedOperation: appleAuth.Operation.LOGIN,
328338
requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
329339
});
330340
```
341+
331342
- For testing purposes, to be receive these again, go to your device settings; `Settings > Apple ID, iCloud, iTunes & App Store > Password & Security > Apps Using Your Apple ID`, tap on your app and tap `Stop Using Apple ID`. You can now sign-in again and you'll receive the `full name` and `email.
332343
- Keep in mind you can always access the `email` property server-side by inspecting the `id_token` returned from Apple when verifying the user.
333344

334345
2. How to change button language? (iOS)
335346
- Native Apple Button component reads language value from CFBundleDevelopmentRegion at Info.plist file. By changing CFBundleDevelopmentRegion value you can change default language for component.
347+
336348
```XML
337349
<key>CFBundleDevelopmentRegion</key>
338350
<string>en</string>
339351
```
352+
340353
- For supporting multi language, you can add CFBundleAllowMixedLocalizations key to Info.plist.
354+
341355
```XML
342356
<key>CFBundleAllowMixedLocalizations</key>
343357
<string>true</string>
344358
```
359+
345360
3. How do I get the email after the first login?
346361
- You can get the email address by parsing the JWT token that's returned from any authentication, like so:
362+
347363
```js
348364
import { appleAuth } from '@invertase/react-native-apple-authentication';
349365
import { jwtDecode } from 'jwt-decode';
@@ -362,16 +378,19 @@ All API documentation is generated by typedoc, and [is available in the `typedoc
362378
The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1000.)
363379
```
364380
365-
###### Case 1:
381+
###### Case 1
382+
366383
Check that the connection settings have been made correctly.
367384
The setup can be found here: [Initial Setup](https://github.com/invertase/react-native-apple-authentication/blob/main/docs/INITIAL_SETUP.md)
368385
369-
###### Case 2:
386+
###### Case 2
387+
370388
If you are using the function `getCredentialStateForUser` on a simulator, this error will always be triggered, for the reason that this function verifies the authenticity of the device.
371389
372390
You must test your code on a real device.
373391
374-
###### Case 3:
392+
###### Case 3
393+
375394
If you are using a simulator, go to [Manage Apple Account](https://appleid.apple.com/account/manage).
376395
377396
Search for "Devices", select "Simulator" and press "Remove from Account".
@@ -385,21 +404,53 @@ It should work fine.
385404
```
386405
"invalid_client" in Android webview
387406
```
407+
388408
Make sure to read the Android [services setup docs](docs/ANDROID_EXTRA.md).
389409
390-
###### Case 1:
410+
###### Case 1
411+
391412
The `clientId` you passed to `appleAuthAndroid.configure` doesn't match the Service ID you setup in your Apple developer console.
392413
393-
###### Case 2:
414+
###### Case 2
415+
394416
Your Service ID is attached to the wrong Primary App ID, and therefore uses the incorrect Sign In with Apple key.
395417
396-
###### Case 3:
418+
###### Case 3
419+
397420
The `redirectUri` you passed to `appleAuthAndroid.configure` doesn't match one of the return URLs or domains/subdomains you added in your Apple developer console. The URL must match *exactly*, and cannot contain a query string.
398421
399422
## License
400423
401424
- See [LICENSE](/LICENSE)
402425
426+
## Example app construction
427+
428+
This section is intended for people maintaining the module.
429+
430+
`react-native-test-app` is used for the example, to refresh it this is the general path:
431+
432+
- use yarn to update the react-native-test-app package in the package.json
433+
- move the existing example app(s) to a side space (e.g., example-OLD)
434+
- create the main test app (for android and ios, which are current)
435+
- `yarn init-test-app`
436+
- name the app `RNAppleAuthExample`
437+
- choose ios and android only as the platforms (the others lag in versions)
438+
- create the new project in `example` directory
439+
- `touch example/yarn.lock` so that yarn will consider it to be separate
440+
- copy old example files to new example:
441+
- the old app.json (it sets up single-app mode and the apple entitlements)
442+
- the old index.*and app.* images and ios/example.entitlements files
443+
- remove the App.tsx file
444+
- add our package as a dependency '"@invertase/react-native-apple-auth": "portal:../"'
445+
- other packages `yarn add react-native-get-random-values base-64 jwt-decode`
446+
- add the `path` require and our package dir to watch folders in metro.config.js as
447+
it was in the old example
448+
449+
- Now make a second one, but for the platforms which lag behind mainline react-native:
450+
- `yarn init-test-app --version 0.79`, name RNAppleAuthExample, example-other
451+
- now do the same steps as above
452+
- the index.ios.js and app.ios.js files need to be copied to *.macos.*
453+
403454
---
404455
405456
<p align="center">

example-other/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: ".bundle"
2+
BUNDLE_FORCE_RUBY_PLATFORM: 1

example-other/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.binlog
2+
*.hprof
3+
*.xcworkspace/
4+
*.zip
5+
.DS_Store
6+
.bundle/*
7+
!.bundle/config
8+
.gradle/
9+
.idea/
10+
.vs/
11+
.xcode.env
12+
Pods/
13+
build/
14+
dist/*
15+
!dist/.gitignore
16+
local.properties
17+
msbuild.binlog
18+
node_modules/

example-other/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example-other/Gemfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
source 'https://rubygems.org'
2+
3+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
ruby ">= 2.6.10"
5+
6+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
7+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
10+
gem 'concurrent-ruby', '< 1.3.4'
11+
12+
# Ruby 3.4.0 has removed some libraries from the standard library.
13+
gem 'bigdecimal'
14+
gem 'logger'
15+
gem 'benchmark'
16+
gem 'mutex_m'

0 commit comments

Comments
 (0)