@@ -6,18 +6,71 @@ React-Native custom library which provides short discovery about how to integrat
6
6
## Installation
7
7
8
8
``` sh
9
- npm install react-native-modifier
9
+ yarn install
10
+
11
+ ** For run example workspace directly:**
12
+ yarn example android
13
+ yarn example ios
14
+
15
+ ** For Android example run:**
16
+ yarn android
17
+
18
+ ** For iOS example run:**
19
+ cd ios
20
+ pod install
21
+ cd ..
22
+ yarn ios
10
23
```
11
24
12
25
## Usage
13
26
14
27
15
28
``` js
16
29
import { multiply } from ' react-native-modifier' ;
17
-
30
+ ** OR **
31
+ import { methodModifier , signInWithApple , configureAndroidAppleAuth , AppleSigninButton } from ' react-native-modifier' ;
18
32
// ...
19
33
20
34
const result = multiply (3 , 7 );
35
+
36
+ // Configure and run Apple signin and get the signin response
37
+ const onAppleSigning = useCallback (async () => {
38
+ try {
39
+ if (Platform .OS == ' android' ) {
40
+ await configureAndroidAppleAuth ({
41
+ // The Service ID you registered with Apple
42
+ clientId: ' {your Apple service Id}' ,
43
+ // Return URL added to your Apple dev console. We intercept this redirect, but it must still match
44
+ // the URL you provided to Apple. It can be an empty route on your backend as it's never called.
45
+ redirectUri: ' {your app service call back url}' ,
46
+ });
47
+ }
48
+
49
+ let result = await signInWithApple ();
50
+ console .log (' result....' , result);
51
+ } catch (error) {
52
+ console .log (' error....' , error);
53
+ }
54
+ }, []);
55
+
56
+ ** Apple signin failure or success response from native iOS side using event listener**
57
+ useEffect (() => {
58
+ calculate ();
59
+ eventEmitter .addListener (' onSigninComplete' , (event ) => {
60
+ console .log (' Event Success received from Swift:' , event );
61
+ });
62
+ eventEmitter .addListener (' onSigninFail' , (event ) => {
63
+ console .log (' Event Error received from Swift:' , event );
64
+ });
65
+
66
+ return () => {
67
+ eventEmitter .removeAllListeners (' onSigninComplete' );
68
+ eventEmitter .removeAllListeners (' onSigninFail' );
69
+ };
70
+ }, []);
71
+
72
+ // Render AppleSigninButton UI directly from native iOS swift code
73
+ {Platform .OS == ' ios' && (< AppleSigninButton style= {styles .appleButtonStyle } / > )}
21
74
```
22
75
23
76
0 commit comments