You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Copy file name to clipboardExpand all lines: README.md
+60-9Lines changed: 60 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ The `@invertase/react-native-apple-authentication` library will not work if you
32
32
-**Once you're sure you've met the above, please follow our [Initial development environment setup](docs/INITIAL_SETUP.md) guide.**
33
33
34
34
## Version 2.0.0 breaking changes
35
+
35
36
Version 2 added Android support and introduced a few breaking changes with how methods are accessed. Please see the [Migration Guide](docs/MIGRATION.md).
36
37
37
38
## Installation
@@ -47,6 +48,7 @@ You will not have to manually link this module as it supports React Native auto-
47
48
### Expo usage
48
49
49
50
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
+
50
52
```json
51
53
{
52
54
"expo": {
@@ -70,7 +72,6 @@ Below are simple steps to help you get up and running. The implementation differ
70
72
- If you're authenticating users via `React Native Firebase`; see our [Firebase guide](docs/FIREBASE.md)
71
73
- For Android support, a couple extra steps are required on your Apple developer account. Checkout [our guide](docs/ANDROID_EXTRA.md) for more info.
72
74
73
-
74
75
### iOS
75
76
76
77
#### 1. Initial set-up
@@ -106,6 +107,7 @@ function App() {
106
107
```
107
108
108
109
#### 2. Implement the login process
110
+
109
111
```js
110
112
// App.js
111
113
@@ -166,7 +168,9 @@ So it is recommended when logging out to just clear all data you have from a use
166
168
### Android
167
169
168
170
#### 1. Initial set-up
171
+
169
172
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
+
170
174
```js
171
175
// App.js
172
176
@@ -194,6 +198,7 @@ function App() {
194
198
```
195
199
196
200
#### 2. Implement the login process
201
+
197
202
```js
198
203
// App.js
199
204
@@ -235,19 +240,19 @@ async function onAppleButtonPress() {
235
240
}
236
241
```
237
242
238
-
239
243
### MacOS
240
244
241
245
This library works on MacOS 10.15+ if using in conjunction with [react-native-macos](https://github.com/microsoft/react-native-macos).
242
246
243
-
244
247
### Web (not react-native-web, but that may come as a follow-on, this is pure web at the moment)
245
248
246
249
#### 1. Initial set-up
250
+
247
251
- Ensure you follow the android steps above.
248
252
- Install the [web counterpart](https://github.com/A-Tokyo/react-apple-signin-auth)`yarn add react-apple-signin-auth` in your web project.
- See [Serverside Verification](#serverside-verification)
294
300
- 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.
- 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.
301
307
- To verify the nonce serverside you first need to hash the nonce value, ie:
- The nonce can then be easily compared serverside for extra security verification, ie:
314
+
306
315
```js
307
316
importcryptofrom'crypto';
308
317
importappleSigninAuthfrom'apple-signin-auth';
@@ -322,28 +331,35 @@ All API documentation is generated by typedoc, and [is available in the `typedoc
322
331
1. Why does `full name` and `email` return `null`?
323
332
- 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.
324
333
- 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:
- 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.
332
343
- Keep in mind you can always access the `email` property server-side by inspecting the `id_token` returned from Apple when verifying the user.
333
344
334
345
2. How to change button language? (iOS)
335
346
- 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
+
336
348
```XML
337
349
<key>CFBundleDevelopmentRegion</key>
338
350
<string>en</string>
339
351
```
352
+
340
353
- For supporting multi language, you can add CFBundleAllowMixedLocalizations key to Info.plist.
354
+
341
355
```XML
342
356
<key>CFBundleAllowMixedLocalizations</key>
343
357
<string>true</string>
344
358
```
359
+
345
360
3. How do I get the email after the first login?
346
361
- You can get the email address by parsing the JWT token that's returned from any authentication, like so:
362
+
347
363
```js
348
364
import { appleAuth } from '@invertase/react-native-apple-authentication';
349
365
import { jwtDecode } from 'jwt-decode';
@@ -362,16 +378,19 @@ All API documentation is generated by typedoc, and [is available in the `typedoc
362
378
The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1000.)
363
379
```
364
380
365
-
###### Case 1:
381
+
###### Case 1
382
+
366
383
Check that the connection settings have been made correctly.
367
384
The setup can be found here: [Initial Setup](https://github.com/invertase/react-native-apple-authentication/blob/main/docs/INITIAL_SETUP.md)
368
385
369
-
###### Case 2:
386
+
###### Case 2
387
+
370
388
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.
371
389
372
390
You must test your code on a real device.
373
391
374
-
###### Case 3:
392
+
###### Case 3
393
+
375
394
If you are using a simulator, go to [Manage Apple Account](https://appleid.apple.com/account/manage).
376
395
377
396
Search for "Devices", select "Simulator" and press "Remove from Account".
@@ -385,21 +404,53 @@ It should work fine.
385
404
```
386
405
"invalid_client" in Android webview
387
406
```
407
+
388
408
Make sure to read the Android [services setup docs](docs/ANDROID_EXTRA.md).
389
409
390
-
###### Case 1:
410
+
###### Case 1
411
+
391
412
The `clientId` you passed to `appleAuthAndroid.configure` doesn't match the Service ID you setup in your Apple developer console.
392
413
393
-
###### Case 2:
414
+
###### Case 2
415
+
394
416
Your Service ID is attached to the wrong Primary App ID, and therefore uses the incorrect Sign In with Apple key.
395
417
396
-
###### Case 3:
418
+
###### Case 3
419
+
397
420
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.
398
421
399
422
## License
400
423
401
424
- See [LICENSE](/LICENSE)
402
425
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.*
0 commit comments