@rownd/react-native 0.2.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +15 -52
- package/android/build.gradle +127 -37
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +98 -0
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +16 -0
- package/ios/{ReactNative.xcodeproj → Rownd.xcodeproj}/project.pbxproj +13 -12
- package/ios/Rownd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/RowndPlugin-Bridging-Header.h +3 -0
- package/ios/RowndPlugin.m +26 -0
- package/ios/RowndPlugin.swift +83 -0
- package/ios/RowndPluginEventEmitter.m +12 -0
- package/ios/RowndPluginEventEmitter.swift +19 -0
- package/lib/commonjs/components/GlobalContext.js +30 -298
- package/lib/commonjs/components/GlobalContext.js.map +1 -1
- package/lib/commonjs/components/{BottomSheetTextInput/types.js → GlobalContext.types.js} +1 -1
- package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
- package/lib/commonjs/constants/action.js +13 -0
- package/lib/commonjs/constants/action.js.map +1 -0
- package/lib/commonjs/hooks/rownd.js +15 -146
- package/lib/commonjs/hooks/rownd.js.map +1 -1
- package/lib/commonjs/index.js +2 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/reducer/rowndReducer.js +89 -0
- package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
- package/lib/commonjs/utils/config.js +0 -26
- package/lib/commonjs/utils/config.js.map +1 -1
- package/lib/commonjs/utils/nativeModule.js +72 -0
- package/lib/commonjs/utils/nativeModule.js.map +1 -0
- package/lib/module/components/GlobalContext.js +29 -293
- package/lib/module/components/GlobalContext.js.map +1 -1
- package/lib/module/components/GlobalContext.types.js +2 -0
- package/lib/module/components/GlobalContext.types.js.map +1 -0
- package/lib/module/constants/action.js +6 -0
- package/lib/module/constants/action.js.map +1 -0
- package/lib/module/hooks/rownd.js +12 -137
- package/lib/module/hooks/rownd.js.map +1 -1
- package/lib/module/index.js +2 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/reducer/rowndReducer.js +78 -0
- package/lib/module/reducer/rowndReducer.js.map +1 -0
- package/lib/module/utils/config.js +1 -16
- package/lib/module/utils/config.js.map +1 -1
- package/lib/module/utils/nativeModule.js +48 -0
- package/lib/module/utils/nativeModule.js.map +1 -0
- package/lib/typescript/components/GlobalContext.d.ts +13 -0
- package/lib/typescript/{src/components/GlobalContext.d.ts → components/GlobalContext.types.d.ts} +9 -35
- package/lib/typescript/constants/action.d.ts +7 -0
- package/lib/typescript/{src/hooks → hooks}/rownd.d.ts +10 -13
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
- package/lib/typescript/utils/config.d.ts +10 -0
- package/lib/typescript/utils/nativeModule.d.ts +10 -0
- package/package.json +36 -56
- package/rownd-react-native.podspec +36 -0
- package/src/components/GlobalContext.tsx +44 -457
- package/src/components/GlobalContext.types.ts +105 -0
- package/src/constants/action.ts +8 -0
- package/src/hooks/rownd.ts +29 -147
- package/src/index.tsx +2 -4
- package/src/reducer/rowndReducer.ts +78 -0
- package/src/utils/config.ts +0 -27
- package/src/utils/nativeModule.ts +69 -0
- package/android/src/main/java/com/reactnative/ReactNativePackage.java +0 -22
- package/android/src/main/java/com/reactnative/ReactNativeViewManager.java +0 -31
- package/ios/ReactNativeViewManager.m +0 -34
- package/lib/commonjs/assets/images/checkmark--filled.svg +0 -12
- package/lib/commonjs/assets/images/email-verify-waiting.svg +0 -36
- package/lib/commonjs/assets/images/error-icon-material.svg +0 -1
- package/lib/commonjs/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/commonjs/components/AuthenticatedComponent.js +0 -35
- package/lib/commonjs/components/AuthenticatedComponent.js.map +0 -1
- package/lib/commonjs/components/AutoSigninDialog.js +0 -132
- package/lib/commonjs/components/AutoSigninDialog.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -65
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/index.js +0 -24
- package/lib/commonjs/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/commonjs/components/DarkText.js +0 -35
- package/lib/commonjs/components/DarkText.js.map +0 -1
- package/lib/commonjs/components/DefaultContext.js +0 -266
- package/lib/commonjs/components/DefaultContext.js.map +0 -1
- package/lib/commonjs/components/RowndComponents.js +0 -25
- package/lib/commonjs/components/RowndComponents.js.map +0 -1
- package/lib/commonjs/components/RowndProvider.js +0 -55
- package/lib/commonjs/components/RowndProvider.js.map +0 -1
- package/lib/commonjs/components/SignIn.js +0 -644
- package/lib/commonjs/components/SignIn.js.map +0 -1
- package/lib/commonjs/components/images/CheckmarkFilled.js +0 -40
- package/lib/commonjs/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/commonjs/components/images/EmailVerifyWaiting.js +0 -100
- package/lib/commonjs/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/commonjs/components/images/ErrorIcon.js +0 -31
- package/lib/commonjs/components/images/ErrorIcon.js.map +0 -1
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js +0 -91
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/commonjs/data/actions.js +0 -26
- package/lib/commonjs/data/actions.js.map +0 -1
- package/lib/commonjs/hooks/api.js +0 -155
- package/lib/commonjs/hooks/api.js.map +0 -1
- package/lib/commonjs/hooks/debounce.js +0 -38
- package/lib/commonjs/hooks/debounce.js.map +0 -1
- package/lib/commonjs/hooks/fingerprint.js +0 -176
- package/lib/commonjs/hooks/fingerprint.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -48
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/interval.js +0 -31
- package/lib/commonjs/hooks/interval.js.map +0 -1
- package/lib/commonjs/hooks/nav.js +0 -39
- package/lib/commonjs/hooks/nav.js.map +0 -1
- package/lib/commonjs/index.tsx.bak +0 -26
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/events.js +0 -57
- package/lib/commonjs/utils/events.js.map +0 -1
- package/lib/commonjs/utils/form.js +0 -46
- package/lib/commonjs/utils/form.js.map +0 -1
- package/lib/commonjs/utils/queue.js +0 -117
- package/lib/commonjs/utils/queue.js.map +0 -1
- package/lib/commonjs/utils/storage.js +0 -15
- package/lib/commonjs/utils/storage.js.map +0 -1
- package/lib/commonjs/utils/tokens.js +0 -35
- package/lib/commonjs/utils/tokens.js.map +0 -1
- package/lib/commonjs/utils/user-data.js +0 -21
- package/lib/commonjs/utils/user-data.js.map +0 -1
- package/lib/module/assets/images/checkmark--filled.svg +0 -12
- package/lib/module/assets/images/email-verify-waiting.svg +0 -36
- package/lib/module/assets/images/error-icon-material.svg +0 -1
- package/lib/module/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/module/components/AuthenticatedComponent.js +0 -24
- package/lib/module/components/AuthenticatedComponent.js.map +0 -1
- package/lib/module/components/AutoSigninDialog.js +0 -110
- package/lib/module/components/AutoSigninDialog.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -52
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/index.js +0 -5
- package/lib/module/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/types.js +0 -2
- package/lib/module/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/module/components/DarkText.js +0 -24
- package/lib/module/components/DarkText.js.map +0 -1
- package/lib/module/components/DefaultContext.js +0 -244
- package/lib/module/components/DefaultContext.js.map +0 -1
- package/lib/module/components/RowndComponents.js +0 -12
- package/lib/module/components/RowndComponents.js.map +0 -1
- package/lib/module/components/RowndProvider.js +0 -39
- package/lib/module/components/RowndProvider.js.map +0 -1
- package/lib/module/components/SignIn.js +0 -616
- package/lib/module/components/SignIn.js.map +0 -1
- package/lib/module/components/images/CheckmarkFilled.js +0 -27
- package/lib/module/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/module/components/images/EmailVerifyWaiting.js +0 -87
- package/lib/module/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/module/components/images/ErrorIcon.js +0 -18
- package/lib/module/components/images/ErrorIcon.js.map +0 -1
- package/lib/module/components/images/PhoneVerifyWaiting.js +0 -78
- package/lib/module/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/module/data/actions.js +0 -19
- package/lib/module/data/actions.js.map +0 -1
- package/lib/module/hooks/api.js +0 -135
- package/lib/module/hooks/api.js.map +0 -1
- package/lib/module/hooks/debounce.js +0 -29
- package/lib/module/hooks/debounce.js.map +0 -1
- package/lib/module/hooks/fingerprint.js +0 -157
- package/lib/module/hooks/fingerprint.js.map +0 -1
- package/lib/module/hooks/index.js +0 -7
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/interval.js +0 -23
- package/lib/module/hooks/interval.js.map +0 -1
- package/lib/module/hooks/nav.js +0 -30
- package/lib/module/hooks/nav.js.map +0 -1
- package/lib/module/index.tsx.bak +0 -26
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/events.js +0 -45
- package/lib/module/utils/events.js.map +0 -1
- package/lib/module/utils/form.js +0 -34
- package/lib/module/utils/form.js.map +0 -1
- package/lib/module/utils/queue.js +0 -109
- package/lib/module/utils/queue.js.map +0 -1
- package/lib/module/utils/storage.js +0 -6
- package/lib/module/utils/storage.js.map +0 -1
- package/lib/module/utils/tokens.js +0 -24
- package/lib/module/utils/tokens.js.map +0 -1
- package/lib/module/utils/user-data.js +0 -14
- package/lib/module/utils/user-data.js.map +0 -1
- package/lib/package.json +0 -173
- package/lib/typescript/src/components/AuthenticatedComponent.d.ts +0 -7
- package/lib/typescript/src/components/AutoSigninDialog.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/BottomSheetTextInput.d.ts +0 -4
- package/lib/typescript/src/components/BottomSheetTextInput/index.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/types.d.ts +0 -3
- package/lib/typescript/src/components/DarkText.d.ts +0 -3
- package/lib/typescript/src/components/DefaultContext.d.ts +0 -12
- package/lib/typescript/src/components/RowndComponents.d.ts +0 -2
- package/lib/typescript/src/components/RowndProvider.d.ts +0 -8
- package/lib/typescript/src/components/SignIn.d.ts +0 -2
- package/lib/typescript/src/components/images/CheckmarkFilled.d.ts +0 -4
- package/lib/typescript/src/components/images/EmailVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/components/images/ErrorIcon.d.ts +0 -4
- package/lib/typescript/src/components/images/PhoneVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/data/actions.d.ts +0 -20
- package/lib/typescript/src/hooks/api.d.ts +0 -12
- package/lib/typescript/src/hooks/debounce.d.ts +0 -5
- package/lib/typescript/src/hooks/fingerprint.d.ts +0 -12
- package/lib/typescript/src/hooks/index.d.ts +0 -6
- package/lib/typescript/src/hooks/interval.d.ts +0 -2
- package/lib/typescript/src/hooks/nav.d.ts +0 -6
- package/lib/typescript/src/index.d.ts +0 -4
- package/lib/typescript/src/types.d.ts +0 -26
- package/lib/typescript/src/utils/config.d.ts +0 -18
- package/lib/typescript/src/utils/events.d.ts +0 -22
- package/lib/typescript/src/utils/form.d.ts +0 -18
- package/lib/typescript/src/utils/queue.d.ts +0 -21
- package/lib/typescript/src/utils/storage.d.ts +0 -3
- package/lib/typescript/src/utils/tokens.d.ts +0 -4
- package/lib/typescript/src/utils/user-data.d.ts +0 -3
- package/react-native.podspec +0 -19
- package/src/assets/images/checkmark--filled.svg +0 -12
- package/src/assets/images/email-verify-waiting.svg +0 -36
- package/src/assets/images/error-icon-material.svg +0 -1
- package/src/assets/images/phone-verify-waiting.svg +0 -26
- package/src/components/AuthenticatedComponent.tsx +0 -30
- package/src/components/AutoSigninDialog.tsx +0 -131
- package/src/components/BottomSheetTextInput/BottomSheetTextInput.tsx +0 -57
- package/src/components/BottomSheetTextInput/index.ts +0 -5
- package/src/components/BottomSheetTextInput/types.ts +0 -3
- package/src/components/DarkText.tsx +0 -16
- package/src/components/DefaultContext.tsx +0 -278
- package/src/components/RowndComponents.tsx +0 -18
- package/src/components/RowndProvider.tsx +0 -56
- package/src/components/SignIn.tsx +0 -797
- package/src/components/images/CheckmarkFilled.tsx +0 -30
- package/src/components/images/EmailVerifyWaiting.tsx +0 -95
- package/src/components/images/ErrorIcon.tsx +0 -11
- package/src/components/images/PhoneVerifyWaiting.tsx +0 -74
- package/src/data/actions.ts +0 -21
- package/src/hooks/api.ts +0 -162
- package/src/hooks/debounce.ts +0 -36
- package/src/hooks/fingerprint.ts +0 -217
- package/src/hooks/index.ts +0 -7
- package/src/hooks/interval.ts +0 -25
- package/src/hooks/nav.tsx +0 -29
- package/src/index.tsx.bak +0 -26
- package/src/types.ts +0 -27
- package/src/utils/events.ts +0 -54
- package/src/utils/form.tsx +0 -64
- package/src/utils/queue.ts +0 -75
- package/src/utils/storage.ts +0 -7
- package/src/utils/tokens.ts +0 -26
- package/src/utils/user-data.ts +0 -15
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
3
|
+
Copyright (c) 2022 rownd
|
|
5
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
5
|
of this software and associated documentation files (the "Software"), to deal
|
|
7
6
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
|
@@ -13,59 +13,30 @@ First, install the Rownd SDK for React Native.
|
|
|
13
13
|
npm install @rownd/react-native
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
> If you already use `react-native-gesture-handler` and/or `react-native-reanimated` run the following command:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
npm install @gorhom/bottom-sheet@2 @react-native-clipboard/clipboard \
|
|
22
|
-
react-native-device-info react-native-gesture-handler@1 react-native-mmkv \
|
|
23
|
-
react-native-reanimated@1 react-native-sha256 react-native-svg
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
> If you **do not** use the aforementioned libraries _or_ are on v2.x, run this command instead:
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
npm install @gorhom/bottom-sheet @react-native-clipboard/clipboard \
|
|
30
|
-
react-native-device-info react-native-gesture-handler react-native-mmkv \
|
|
31
|
-
react-native-reanimated react-native-sha256 react-native-svg
|
|
32
|
-
```
|
|
16
|
+
### Android
|
|
33
17
|
|
|
18
|
+
```sh
|
|
19
|
+
cd android
|
|
20
|
+
```
|
|
21
|
+
```sh
|
|
22
|
+
./gradlew build
|
|
23
|
+
```
|
|
34
24
|
|
|
35
|
-
|
|
25
|
+
### iOS
|
|
36
26
|
|
|
37
27
|
```sh
|
|
38
|
-
|
|
28
|
+
cd ios
|
|
29
|
+
```
|
|
30
|
+
```sh
|
|
31
|
+
pod install
|
|
39
32
|
```
|
|
40
33
|
|
|
41
34
|
## Setup
|
|
42
35
|
|
|
43
36
|
### Enable deep linking
|
|
44
37
|
Rownd supports automatically signing-in users when they initially install your
|
|
45
|
-
app or when they click a sign-in link when the app is already installed.
|
|
46
|
-
|
|
47
|
-
In order to enable the latter case, the Rownd SDK needs to know which URL
|
|
48
|
-
triggered the app to launch, in case it was one of the special sign-in links.
|
|
49
|
-
|
|
50
|
-
To enable this functionality, follow [the instructions for configuring a
|
|
51
|
-
React Native app to receive deep links.](https://reactnative.dev/docs/linking)
|
|
52
|
-
### Add Gesture Handler
|
|
38
|
+
app or when they click a sign-in link when the app is already installed.
|
|
53
39
|
|
|
54
|
-
Unless you already use `react-native-gesture-handler', include it within your app's root, wrapping your component tree like this:
|
|
55
|
-
|
|
56
|
-
```tsx
|
|
57
|
-
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
58
|
-
|
|
59
|
-
// ...
|
|
60
|
-
|
|
61
|
-
export default function Root() {
|
|
62
|
-
return (
|
|
63
|
-
<GestureHandlerRootView>
|
|
64
|
-
<App />
|
|
65
|
-
</GestureHandlerRootView>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
40
|
|
|
70
41
|
## Usage
|
|
71
42
|
The Rownd SDK includes a context provider that will enable any component of your app to access authentication state and user data.
|
|
@@ -79,11 +50,9 @@ import { RowndProvider } from "@rownd/react-native";
|
|
|
79
50
|
|
|
80
51
|
export default function Root() {
|
|
81
52
|
return (
|
|
82
|
-
<GestureHandlerRootView>
|
|
83
53
|
<RowndProvider appKey="<your app key>">
|
|
84
54
|
<App />
|
|
85
55
|
</RowndProvider>
|
|
86
|
-
</GestureHandlerRootView>
|
|
87
56
|
);
|
|
88
57
|
}
|
|
89
58
|
```
|
|
@@ -92,7 +61,7 @@ Later on within your app's components, you can use the Rownd hook to access the
|
|
|
92
61
|
|
|
93
62
|
```tsx
|
|
94
63
|
import { View, Text } from 'react-native';
|
|
95
|
-
import { useRownd } from '@rownd/react';
|
|
64
|
+
import { useRownd } from '@rownd/react-native';
|
|
96
65
|
|
|
97
66
|
export default function MyProtectedComponent(props) {
|
|
98
67
|
const { is_authenticated, user, requestSignIn, getAccessToken } = useRownd();
|
|
@@ -136,15 +105,9 @@ Trigger the Rownd sign in dialog
|
|
|
136
105
|
```javascript
|
|
137
106
|
const { requestSignIn } = useRownd();
|
|
138
107
|
|
|
139
|
-
requestSignIn(
|
|
140
|
-
auto_sign_in: false, // optional
|
|
141
|
-
identifier: 'me@company.com' || '+19105551212' // optional
|
|
142
|
-
});
|
|
108
|
+
requestSignIn();
|
|
143
109
|
```
|
|
144
110
|
|
|
145
|
-
* `auto_sign_in: boolean` - when `true`, automatically trigger a sign-in attempt _if_ `identifier` is included or an email address or phone number has already been set in the user data.
|
|
146
|
-
* `identifier: string` - an email address or phone number (in E164 format) to which a verification message may be sent. If the Rownd app is configured to allow unverified users, then sign-in will complete without verification if the user has not signed in previously.
|
|
147
|
-
|
|
148
111
|
#### signOut()
|
|
149
112
|
|
|
150
113
|
Sign out the user and clear their profile, returning them to a completely unauthenticated state.
|
package/android/build.gradle
CHANGED
|
@@ -1,59 +1,149 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
google()
|
|
5
|
-
mavenCentral()
|
|
6
|
-
jcenter()
|
|
7
|
-
}
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RowndPlugin_kotlinVersion']
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath 'com.android.tools.build:gradle:3.5.3'
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
def isNewArchitectureEnabled() {
|
|
19
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
apply plugin: 'com.android.library'
|
|
23
|
+
apply plugin: 'kotlin-android'
|
|
24
|
+
apply plugin: 'kotlinx-serialization'
|
|
25
|
+
|
|
26
|
+
if (isNewArchitectureEnabled()) {
|
|
27
|
+
apply plugin: 'com.facebook.react'
|
|
28
|
+
}
|
|
16
29
|
|
|
17
|
-
def
|
|
18
|
-
|
|
30
|
+
def getExtOrDefault(name) {
|
|
31
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RowndPlugin_' + name]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
def getExtOrIntegerDefault(name) {
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RowndPlugin_' + name]).toInteger()
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
android {
|
|
22
|
-
|
|
23
|
-
defaultConfig {
|
|
24
|
-
minSdkVersion safeExtGet('ReactNative_minSdkVersion', 16)
|
|
25
|
-
targetSdkVersion safeExtGet('ReactNative_targetSdkVersion', 29)
|
|
26
|
-
versionCode 1
|
|
27
|
-
versionName "1.0"
|
|
39
|
+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
28
40
|
|
|
41
|
+
defaultConfig {
|
|
42
|
+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
43
|
+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
44
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
45
|
+
}
|
|
46
|
+
buildTypes {
|
|
47
|
+
release {
|
|
48
|
+
minifyEnabled false
|
|
29
49
|
}
|
|
50
|
+
}
|
|
30
51
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
compileOptions {
|
|
40
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
41
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
42
|
-
}
|
|
52
|
+
lintOptions {
|
|
53
|
+
disable 'GradleCompatible'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
compileOptions {
|
|
57
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
58
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
59
|
+
}
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
repositories {
|
|
46
|
-
|
|
63
|
+
mavenCentral()
|
|
64
|
+
google()
|
|
65
|
+
|
|
66
|
+
def found = false
|
|
67
|
+
def defaultDir = null
|
|
68
|
+
def androidSourcesName = 'React Native sources'
|
|
69
|
+
|
|
70
|
+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
71
|
+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
72
|
+
} else {
|
|
73
|
+
defaultDir = new File(
|
|
74
|
+
projectDir,
|
|
75
|
+
'/../../../node_modules/react-native/android'
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (defaultDir.exists()) {
|
|
47
80
|
maven {
|
|
48
|
-
|
|
49
|
-
|
|
81
|
+
url defaultDir.toString()
|
|
82
|
+
name androidSourcesName
|
|
50
83
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
|
|
85
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
86
|
+
found = true
|
|
87
|
+
} else {
|
|
88
|
+
def parentDir = rootProject.projectDir
|
|
89
|
+
|
|
90
|
+
1.upto(5, {
|
|
91
|
+
if (found) return true
|
|
92
|
+
parentDir = parentDir.parentFile
|
|
93
|
+
|
|
94
|
+
def androidSourcesDir = new File(
|
|
95
|
+
parentDir,
|
|
96
|
+
'node_modules/react-native'
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def androidPrebuiltBinaryDir = new File(
|
|
100
|
+
parentDir,
|
|
101
|
+
'node_modules/react-native/android'
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if (androidPrebuiltBinaryDir.exists()) {
|
|
105
|
+
maven {
|
|
106
|
+
url androidPrebuiltBinaryDir.toString()
|
|
107
|
+
name androidSourcesName
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
111
|
+
found = true
|
|
112
|
+
} else if (androidSourcesDir.exists()) {
|
|
113
|
+
maven {
|
|
114
|
+
url androidSourcesDir.toString()
|
|
115
|
+
name androidSourcesName
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
119
|
+
found = true
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!found) {
|
|
125
|
+
throw new GradleException(
|
|
126
|
+
"${project.name}: unable to locate React Native android sources. " +
|
|
127
|
+
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
128
|
+
)
|
|
129
|
+
}
|
|
54
130
|
}
|
|
55
131
|
|
|
132
|
+
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
133
|
+
|
|
56
134
|
dependencies {
|
|
57
135
|
//noinspection GradleDynamicVersion
|
|
58
|
-
|
|
136
|
+
implementation "com.facebook.react:react-native:+"
|
|
137
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
138
|
+
implementation 'io.rownd:android:1.3.2'
|
|
139
|
+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"
|
|
140
|
+
// From node_modules
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (isNewArchitectureEnabled()) {
|
|
144
|
+
react {
|
|
145
|
+
jsRootDir = file("../src/")
|
|
146
|
+
libraryName = "RowndPlugin"
|
|
147
|
+
codegenJavaPackageName = "com.reactnativerowndplugin"
|
|
148
|
+
}
|
|
59
149
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
package com.reactnativerowndplugin
|
|
2
|
+
|
|
3
|
+
import android.os.Handler
|
|
4
|
+
import android.os.Looper
|
|
5
|
+
import androidx.fragment.app.FragmentActivity
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
|
+
import io.rownd.android.Rownd
|
|
9
|
+
import io.rownd.android.models.repos.GlobalState
|
|
10
|
+
import io.rownd.android.models.repos.UserRepo
|
|
11
|
+
import kotlinx.coroutines.*
|
|
12
|
+
import kotlinx.serialization.json.Json
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RowndPluginModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
16
|
+
private var uiThreadHandler = Handler(Looper.getMainLooper())
|
|
17
|
+
private var coroutineScope: Job? = null
|
|
18
|
+
private var isRowndJSInitialized = false
|
|
19
|
+
|
|
20
|
+
override fun getName(): String {
|
|
21
|
+
return "RowndPlugin"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
|
|
25
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
26
|
+
.emit(eventName, params)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
init {
|
|
30
|
+
coroutineScope = CoroutineScope(Dispatchers.IO).launch {
|
|
31
|
+
Rownd.state.collect {
|
|
32
|
+
uiThreadHandler.post{
|
|
33
|
+
val params = Arguments.createMap().apply {
|
|
34
|
+
putString("state", Json.encodeToString(GlobalState.serializer(), it))
|
|
35
|
+
}
|
|
36
|
+
if (isRowndJSInitialized) {
|
|
37
|
+
sendEvent(reactApplicationContext, "update_state", params)
|
|
38
|
+
} else {
|
|
39
|
+
println("ROWND JS: NOT INITIALIZED YET")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Example method
|
|
47
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
48
|
+
@ReactMethod
|
|
49
|
+
fun multiply(a: Int, b: Int, promise: Promise) {
|
|
50
|
+
promise.resolve(a * b * 10)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ReactMethod
|
|
54
|
+
fun configure(appKey: String) {
|
|
55
|
+
Rownd.configure(reactApplicationContext.currentActivity as FragmentActivity, appKey)
|
|
56
|
+
isRowndJSInitialized = true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
fun requestSignIn() {
|
|
61
|
+
Rownd.requestSignIn()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
fun signOut() {
|
|
66
|
+
Rownd.signOut()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun manageAccount() {
|
|
71
|
+
Rownd.manageAccount()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
fun setUserData(data: ReadableMap) {
|
|
76
|
+
UserRepo.set(data.toHashMap())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@ReactMethod
|
|
80
|
+
fun setUserDataValue(key: String, array: ReadableMap) {
|
|
81
|
+
val value = array.toHashMap().entries.find { it.key == "value" }?.value
|
|
82
|
+
if (value != null) {
|
|
83
|
+
UserRepo.set(key, value)
|
|
84
|
+
} else {
|
|
85
|
+
println("ROWND ANDROID PLUGIN: Missing content for value")
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// @ReactMethod
|
|
90
|
+
// suspend fun getAccessToken(promise: Promise) {
|
|
91
|
+
// try {
|
|
92
|
+
// val accessToken = Rownd.getAccessToken()
|
|
93
|
+
// promise.resolve(accessToken ?: "")
|
|
94
|
+
// } catch (e: Throwable) {
|
|
95
|
+
// promise.reject("GET_ACCESS_TOKEN_ERROR: ", e)
|
|
96
|
+
// }
|
|
97
|
+
// }
|
|
98
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.reactnativerowndplugin
|
|
2
|
+
import com.facebook.react.ReactPackage
|
|
3
|
+
import com.facebook.react.bridge.NativeModule
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RowndPluginPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(RowndPluginModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
|
|
11
10
|
5E555C0D2413F4C50049A1A2 /* ReactNative.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* ReactNative.m */; };
|
|
12
|
-
|
|
11
|
+
F4FF95D7245B92E800C19C63 /* ReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* ReactNative.swift */; };
|
|
13
12
|
/* End PBXBuildFile section */
|
|
14
13
|
|
|
15
14
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -26,10 +25,9 @@
|
|
|
26
25
|
|
|
27
26
|
/* Begin PBXFileReference section */
|
|
28
27
|
134814201AA4EA6300B7C361 /* libReactNative.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libReactNative.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
29
|
-
|
|
30
|
-
B3E7B5881CC2AC0600A0062D /* ReactNative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReactNative.h; sourceTree = "<group>"; };
|
|
31
28
|
B3E7B5891CC2AC0600A0062D /* ReactNative.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactNative.m; sourceTree = "<group>"; };
|
|
32
|
-
|
|
29
|
+
F4FF95D5245B92E700C19C63 /* ReactNative-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ReactNative-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
30
|
+
F4FF95D6245B92E800C19C63 /* ReactNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactNative.swift; sourceTree = "<group>"; };
|
|
33
31
|
/* End PBXFileReference section */
|
|
34
32
|
|
|
35
33
|
/* Begin PBXFrameworksBuildPhase section */
|
|
@@ -54,10 +52,9 @@
|
|
|
54
52
|
58B511D21A9E6C8500147676 = {
|
|
55
53
|
isa = PBXGroup;
|
|
56
54
|
children = (
|
|
57
|
-
|
|
58
|
-
B3E7B5881CC2AC0600A0062D /* ReactNative.h */,
|
|
55
|
+
F4FF95D6245B92E800C19C63 /* ReactNative.swift */,
|
|
59
56
|
B3E7B5891CC2AC0600A0062D /* ReactNative.m */,
|
|
60
|
-
|
|
57
|
+
F4FF95D5245B92E700C19C63 /* ReactNative-Bridging-Header.h */,
|
|
61
58
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
62
59
|
);
|
|
63
60
|
sourceTree = "<group>";
|
|
@@ -119,9 +116,8 @@
|
|
|
119
116
|
isa = PBXSourcesBuildPhase;
|
|
120
117
|
buildActionMask = 2147483647;
|
|
121
118
|
files = (
|
|
122
|
-
|
|
119
|
+
F4FF95D7245B92E800C19C63 /* ReactNative.swift in Sources */,
|
|
123
120
|
B3E7B58A1CC2AC0600A0062D /* ReactNative.m in Sources */,
|
|
124
|
-
|
|
125
121
|
);
|
|
126
122
|
runOnlyForDeploymentPostprocessing = 0;
|
|
127
123
|
};
|
|
@@ -156,6 +152,7 @@
|
|
|
156
152
|
COPY_PHASE_STRIP = NO;
|
|
157
153
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
158
154
|
ENABLE_TESTABILITY = YES;
|
|
155
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
159
156
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
160
157
|
GCC_DYNAMIC_NO_PIC = NO;
|
|
161
158
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
@@ -206,6 +203,7 @@
|
|
|
206
203
|
COPY_PHASE_STRIP = YES;
|
|
207
204
|
ENABLE_NS_ASSERTIONS = NO;
|
|
208
205
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
206
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
209
207
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
210
208
|
GCC_NO_COMMON_BLOCKS = YES;
|
|
211
209
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
@@ -234,7 +232,9 @@
|
|
|
234
232
|
OTHER_LDFLAGS = "-ObjC";
|
|
235
233
|
PRODUCT_NAME = ReactNative;
|
|
236
234
|
SKIP_INSTALL = YES;
|
|
237
|
-
|
|
235
|
+
SWIFT_OBJC_BRIDGING_HEADER = "ReactNative-Bridging-Header.h";
|
|
236
|
+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
|
237
|
+
SWIFT_VERSION = 5.0;
|
|
238
238
|
};
|
|
239
239
|
name = Debug;
|
|
240
240
|
};
|
|
@@ -251,7 +251,8 @@
|
|
|
251
251
|
OTHER_LDFLAGS = "-ObjC";
|
|
252
252
|
PRODUCT_NAME = ReactNative;
|
|
253
253
|
SKIP_INSTALL = YES;
|
|
254
|
-
|
|
254
|
+
SWIFT_OBJC_BRIDGING_HEADER = "ReactNative-Bridging-Header.h";
|
|
255
|
+
SWIFT_VERSION = 5.0;
|
|
255
256
|
};
|
|
256
257
|
name = Release;
|
|
257
258
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(RowndPlugin, NSObject)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(setUserDataValue:(NSString *)key withValue:(id)value)
|
|
7
|
+
RCT_EXTERN_METHOD(setUserData:(NSDictionary<NSString *, id>)data)
|
|
8
|
+
|
|
9
|
+
RCT_EXTERN_METHOD(configure:(NSString *)appKey
|
|
10
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
11
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
12
|
+
|
|
13
|
+
RCT_EXTERN_METHOD(requestSignIn)
|
|
14
|
+
RCT_EXTERN_METHOD(signOut)
|
|
15
|
+
|
|
16
|
+
RCT_EXTERN_METHOD(manageAccount)
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(getAccessToken:
|
|
19
|
+
withResolver:(RCTPromiseResolveBlock)resolve)
|
|
20
|
+
|
|
21
|
+
+ (BOOL)requiresMainQueueSetup
|
|
22
|
+
{
|
|
23
|
+
return NO;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Rownd
|
|
2
|
+
import SwiftUI
|
|
3
|
+
import Combine
|
|
4
|
+
import AnyCodable
|
|
5
|
+
|
|
6
|
+
@objc(RowndPlugin)
|
|
7
|
+
class RowndPlugin: NSObject {
|
|
8
|
+
|
|
9
|
+
@ObservedObject private var state = Rownd.getInstance().state().subscribe { $0 }
|
|
10
|
+
|
|
11
|
+
private var stateCancellable: AnyCancellable?
|
|
12
|
+
|
|
13
|
+
override init() {
|
|
14
|
+
super.init()
|
|
15
|
+
|
|
16
|
+
stateCancellable = state.$current.sink { newState in
|
|
17
|
+
do {
|
|
18
|
+
RowndPluginEventEmitter.emitter.sendEvent(withName: "update_state", body: try newState.toDictionary())
|
|
19
|
+
} catch {
|
|
20
|
+
print("Failed to encode Rownd state: \(String(describing: error))")
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@objc(configure:withResolver:withRejecter:)
|
|
26
|
+
func configure(appKey: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
|
|
27
|
+
Task.init {
|
|
28
|
+
await Rownd.configure(launchOptions: nil, appKey: appKey)
|
|
29
|
+
}
|
|
30
|
+
resolve(appKey)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@objc
|
|
34
|
+
func requestSignIn() -> Void {
|
|
35
|
+
DispatchQueue.main.async {
|
|
36
|
+
Rownd.requestSignIn()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc
|
|
41
|
+
func signOut() -> Void {
|
|
42
|
+
DispatchQueue.main.async {
|
|
43
|
+
Rownd.signOut()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@objc
|
|
48
|
+
func manageAccount() -> Void {
|
|
49
|
+
DispatchQueue.main.async {
|
|
50
|
+
Rownd.manageAccount()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@objc(getAccessToken:withResolver:)
|
|
55
|
+
func getAccessToken(resolve: @escaping RCTPromiseResolveBlock) async -> Void {
|
|
56
|
+
let accessToken = await Rownd.getAccessToken()
|
|
57
|
+
resolve(accessToken)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@objc(setUserData:)
|
|
61
|
+
func setUserData(data: Dictionary<String, Any>) -> Void {
|
|
62
|
+
do {
|
|
63
|
+
let jsonData = try JSONSerialization.data(withJSONObject: data, options: .prettyPrinted)
|
|
64
|
+
let decoder = JSONDecoder()
|
|
65
|
+
let dictionary = try! decoder.decode([String: AnyCodable].self, from: jsonData)
|
|
66
|
+
|
|
67
|
+
Rownd.user.set(data: dictionary)
|
|
68
|
+
} catch {
|
|
69
|
+
print("FAILED TO SET USER DATA: ",error)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@objc(setUserDataValue:withValue:)
|
|
74
|
+
func setUserDataValue(key: String, value: Any) -> Void {
|
|
75
|
+
let json = """
|
|
76
|
+
"\(value)"
|
|
77
|
+
""".data(using: .utf8)!
|
|
78
|
+
|
|
79
|
+
let decoder = JSONDecoder()
|
|
80
|
+
let dictionary = try! decoder.decode(AnyCodable.self, from: json)
|
|
81
|
+
Rownd.user.set(field: key, value: dictionary)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Rownd
|
|
2
|
+
import SwiftUI
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
@objc(RowndPluginEventEmitter)
|
|
6
|
+
class RowndPluginEventEmitter: RCTEventEmitter {
|
|
7
|
+
|
|
8
|
+
public static var emitter: RCTEventEmitter!
|
|
9
|
+
|
|
10
|
+
override init() {
|
|
11
|
+
super.init()
|
|
12
|
+
RowndPluginEventEmitter.emitter = self
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
open override func supportedEvents() -> [String] {
|
|
16
|
+
["update_state","onReady", "onPending", "onFailure"] // etc.
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|