@pinwheel/react-native-pinwheel 3.2.0-rc.4 → 3.2.0-rc.6
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/README.md +45 -31
- package/android/src/main/java/com/rtnpinwheel/Pinwheel.kt +4 -2
- package/ios/RTNPinwheelEvents.h +18 -2
- package/ios/RTNPinwheelEvents.mm +6 -2
- package/ios/RTNPinwheelManager.mm +5 -2
- package/ios/RTNPinwheelView.h +14 -2
- package/ios/RTNPinwheelView.mm +73 -0
- package/package.json +1 -1
- package/src/Pinwheel.tsx +9 -9
package/README.md
CHANGED
|
@@ -2,37 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Pinwheel SDK for React Native
|
|
4
4
|
|
|
5
|
-
## Running The Example App Locally
|
|
6
|
-
|
|
7
|
-
You may want to run the example app locally to get started.
|
|
8
|
-
|
|
9
|
-
#### Dependencies
|
|
10
|
-
|
|
11
|
-
- Node 16.7.0 (check with `node -v` and upgrade versions using `nvm` if needed)
|
|
12
|
-
- iPhone 14 simulator (open your Simulator app and check the available versions)
|
|
13
|
-
- iOS 16 running on the simulator (open your Simulator app and check the available versions)
|
|
14
|
-
- `pod` version 1.11.3 (check with `pod --version`)
|
|
15
|
-
- Add your pinwheel secret to `example/env.js` (create this file) with `export default "<YOUR PINWHEEL SECRET>"`.
|
|
16
|
-
|
|
17
|
-
#### Directions
|
|
18
|
-
|
|
19
|
-
- `npm run dev`
|
|
20
|
-
|
|
21
|
-
#### Troubleshooting
|
|
22
|
-
|
|
23
|
-
###### An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405)
|
|
24
|
-
- Click Apple > About This Mac > Storage > Manage > Developer
|
|
25
|
-
- Delete Xcode cache
|
|
26
|
-
- Delete Project Build and indexes
|
|
27
|
-
|
|
28
|
-
###### Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65
|
|
29
|
-
- Try downloading Xcode 14.2 from https://developer.apple.com/download/all/?q=xcode
|
|
30
|
-
|
|
31
|
-
###### Failed to locate 'git', requesting installation of command line developer tools
|
|
32
|
-
For this or other errors related to command line developer tools:
|
|
33
|
-
- Make sure you have Command Line Tools for Xcode 14.2 installed
|
|
34
|
-
- Open Xcode > Click Xcode in the app menu > Settings > Locations > Command Line Tools dropdown and set the correct location
|
|
35
|
-
|
|
36
5
|
## Installation
|
|
37
6
|
|
|
38
7
|
1. Install Pinwheel React Native SDK
|
|
@@ -41,6 +10,20 @@ For this or other errors related to command line developer tools:
|
|
|
41
10
|
$ npm install --save @pinwheel/react-native-pinwheel
|
|
42
11
|
```
|
|
43
12
|
|
|
13
|
+
## Configuration
|
|
14
|
+
Some platform integrations may require camera access for verification purposes. Ensure the necessary permissions are configured in your project:
|
|
15
|
+
|
|
16
|
+
**Android:** Add the following permission to your `AndroidManifest.xml`:
|
|
17
|
+
```
|
|
18
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**iOS:** Add the following key and description to your `Info.plist`:
|
|
22
|
+
```
|
|
23
|
+
<key>NSCameraUsageDescription</key>
|
|
24
|
+
<string>We need access to your camera for verification purposes.</string>
|
|
25
|
+
```
|
|
26
|
+
|
|
44
27
|
## Usage
|
|
45
28
|
|
|
46
29
|
### Link Token
|
|
@@ -117,3 +100,34 @@ Callback for all significant events that happen during the modal flow. See all p
|
|
|
117
100
|
| Type | Required |
|
|
118
101
|
| -------- | -------- |
|
|
119
102
|
| function | No |
|
|
103
|
+
|
|
104
|
+
## Running The Example App Locally
|
|
105
|
+
|
|
106
|
+
You may want to run the example app locally to get started.
|
|
107
|
+
|
|
108
|
+
#### Dependencies
|
|
109
|
+
|
|
110
|
+
- Node 16.7.0 (check with `node -v` and upgrade versions using `nvm` if needed)
|
|
111
|
+
- iPhone 14 simulator (open your Simulator app and check the available versions)
|
|
112
|
+
- iOS 16 running on the simulator (open your Simulator app and check the available versions)
|
|
113
|
+
- `pod` version 1.11.3 (check with `pod --version`)
|
|
114
|
+
- Add your pinwheel secret to `example/env.js` (create this file) with `export default "<YOUR PINWHEEL SECRET>"`.
|
|
115
|
+
|
|
116
|
+
#### Directions
|
|
117
|
+
|
|
118
|
+
- `npm run dev`
|
|
119
|
+
|
|
120
|
+
#### Troubleshooting
|
|
121
|
+
|
|
122
|
+
###### An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405)
|
|
123
|
+
- Click Apple > About This Mac > Storage > Manage > Developer
|
|
124
|
+
- Delete Xcode cache
|
|
125
|
+
- Delete Project Build and indexes
|
|
126
|
+
|
|
127
|
+
###### Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65
|
|
128
|
+
- Try downloading Xcode 14.2 from https://developer.apple.com/download/all/?q=xcode
|
|
129
|
+
|
|
130
|
+
###### Failed to locate 'git', requesting installation of command line developer tools
|
|
131
|
+
For this or other errors related to command line developer tools:
|
|
132
|
+
- Make sure you have Command Line Tools for Xcode 14.2 installed
|
|
133
|
+
- Open Xcode > Click Xcode in the app menu > Settings > Locations > Command Line Tools dropdown and set the correct location
|
|
@@ -48,7 +48,7 @@ class Pinwheel : FrameLayout {
|
|
|
48
48
|
private fun createFragment() {
|
|
49
49
|
Handler(Looper.getMainLooper()).post {
|
|
50
50
|
this.token?.let {
|
|
51
|
-
val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "3.2.0
|
|
51
|
+
val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "3.2.0")
|
|
52
52
|
pinwheelEventListener?.let { listener ->
|
|
53
53
|
pinwheelFragment.pinwheelEventListener = listener
|
|
54
54
|
}
|
|
@@ -77,13 +77,15 @@ class Pinwheel : FrameLayout {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
fun setupLayoutSizing() {
|
|
80
|
+
val left = this.left
|
|
81
|
+
val top = this.top
|
|
80
82
|
val width = this.width
|
|
81
83
|
val height = this.height
|
|
82
84
|
this.measure(
|
|
83
85
|
View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
|
|
84
86
|
View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY))
|
|
85
87
|
|
|
86
|
-
this.layout(
|
|
88
|
+
this.layout(left, top, left + width, top + height)
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
package/ios/RTNPinwheelEvents.h
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
1
3
|
#import <RTNPinwheelSpec/RTNPinwheelSpec.h>
|
|
4
|
+
|
|
5
|
+
#else
|
|
6
|
+
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
|
|
2
12
|
#import <React/RCTEventEmitter.h>
|
|
3
13
|
|
|
4
14
|
NS_ASSUME_NONNULL_BEGIN
|
|
5
15
|
|
|
6
|
-
@interface RTNPinwheelEvents : RCTEventEmitter
|
|
16
|
+
@interface RTNPinwheelEvents : RCTEventEmitter
|
|
17
|
+
|
|
18
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
19
|
+
<NativePinwheelEventsSpec>
|
|
20
|
+
#else
|
|
21
|
+
<RCTBridgeModule>
|
|
22
|
+
#endif
|
|
7
23
|
|
|
8
24
|
+ (instancetype)sharedInstance;
|
|
9
25
|
- (void)handlePinwheelEvent:(NSDictionary<NSString *, id> *)payload;
|
|
10
26
|
|
|
11
27
|
@end
|
|
12
28
|
|
|
13
|
-
NS_ASSUME_NONNULL_END
|
|
29
|
+
NS_ASSUME_NONNULL_END
|
package/ios/RTNPinwheelEvents.mm
CHANGED
|
@@ -59,16 +59,20 @@ RCT_EXPORT_MODULE();
|
|
|
59
59
|
return @[@"PINWHEEL_EVENT"]; // Add more event names here.
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
62
63
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
63
64
|
return std::make_shared<facebook::react::NativePinwheelEventsSpecJSI>(params);
|
|
64
65
|
}
|
|
66
|
+
#endif
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
RCT_EXPORT_METHOD(removeListener) {
|
|
67
69
|
[self stopObserving];
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
RCT_EXPORT_METHOD(setListener) {
|
|
71
73
|
[self startObserving];
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
|
|
77
|
+
|
|
74
78
|
@end
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
@implementation RTNPinwheelManager
|
|
10
10
|
|
|
11
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
12
|
RCT_EXPORT_MODULE(RTNPinwheelView)
|
|
13
|
+
#else
|
|
14
|
+
RCT_EXPORT_MODULE(RTNPinwheel)
|
|
15
|
+
#endif
|
|
12
16
|
|
|
13
17
|
- (UIView *)view
|
|
14
18
|
{
|
|
15
|
-
|
|
16
|
-
return pv;
|
|
19
|
+
return [[RTNPinwheelView alloc] init];
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
RCT_EXPORT_VIEW_PROPERTY(token, NSString);
|
package/ios/RTNPinwheelView.h
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
1
3
|
#import <React/RCTViewComponentView.h>
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
# endif
|
|
6
|
+
|
|
3
7
|
#import <ObjCWrapper/PinwheelVCWrapper.h>
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
4
9
|
|
|
5
10
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
11
|
|
|
12
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
13
|
+
|
|
7
14
|
@interface RTNPinwheelView : RCTViewComponentView <PinwheelVCWrapperDelegate>
|
|
8
15
|
|
|
16
|
+
#else
|
|
17
|
+
|
|
18
|
+
@interface RTNPinwheelView : UIView <PinwheelVCWrapperDelegate>
|
|
19
|
+
|
|
20
|
+
#endif
|
|
21
|
+
|
|
9
22
|
@property (nonatomic, strong) PinwheelVCWrapper *pinwheelWrapperVC;
|
|
10
23
|
@property (nonatomic, assign) NSString *token;
|
|
11
24
|
|
|
@@ -14,4 +27,3 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
14
27
|
@end
|
|
15
28
|
|
|
16
29
|
NS_ASSUME_NONNULL_END
|
|
17
|
-
|
package/ios/RTNPinwheelView.mm
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
1
3
|
#import "RTNPinwheelView.h"
|
|
2
4
|
|
|
3
5
|
#import <react/renderer/components/RTNPinwheelSpec/ComponentDescriptors.h>
|
|
@@ -100,3 +102,74 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void)
|
|
|
100
102
|
return RTNPinwheelView.class;
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
#else
|
|
106
|
+
|
|
107
|
+
#import "RTNPinwheelView.h"
|
|
108
|
+
#import "RTNPinwheelEvents.h"
|
|
109
|
+
|
|
110
|
+
@implementation RTNPinwheelView
|
|
111
|
+
|
|
112
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
113
|
+
if ((self = [super initWithFrame:frame])) {
|
|
114
|
+
[self initPinwheelWrapperVC];
|
|
115
|
+
}
|
|
116
|
+
return self;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (instancetype)initWithFrame:(CGRect)frame token:(NSString *)token {
|
|
120
|
+
if ((self = [super initWithFrame:frame])) {
|
|
121
|
+
_token = token;
|
|
122
|
+
}
|
|
123
|
+
return self;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)initPinwheelWrapperVC {
|
|
127
|
+
if (self.token != nil && self.pinwheelWrapperVC == nil) {
|
|
128
|
+
self.pinwheelWrapperVC = [[PinwheelVCWrapper alloc] initWithToken:self.token delegate:self sdk:@"react native" version: @"3.2.0"];
|
|
129
|
+
[self addSubview:self.pinwheelWrapperVC.view];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
- (void)setToken:(NSString *)newToken {
|
|
134
|
+
if (![_token isEqualToString:newToken]) {
|
|
135
|
+
_token = newToken;
|
|
136
|
+
[self initPinwheelWrapperVC];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (void)layoutSubviews
|
|
141
|
+
{
|
|
142
|
+
[super layoutSubviews];
|
|
143
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (void)onEventWithName:(NSString *)name event:(NSDictionary<NSString *, id> *)event {
|
|
147
|
+
NSLog(@"%@", name);
|
|
148
|
+
NSDictionary *dataToSend = @{@"name": name, @"payload": event};
|
|
149
|
+
[RTNPinwheelEvents.sharedInstance handlePinwheelEvent:dataToSend];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (void)onExit:(NSDictionary<NSString *, id> *)error {
|
|
153
|
+
NSLog(@"%@", error);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- (void)onSuccess:(NSDictionary<NSString *, id> *)result {
|
|
157
|
+
NSLog(@"%@", result);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)onLogin:(NSDictionary<NSString *, id> *)result {
|
|
161
|
+
NSLog(@"%@", result);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
- (void)onLoginAttempt:(NSDictionary<NSString *, id> *)result {
|
|
165
|
+
NSLog(@"%@", result);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)onError:(NSDictionary<NSString *, id> *)error {
|
|
169
|
+
NSLog(@"%@", error);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@end
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
#endif
|
package/package.json
CHANGED
package/src/Pinwheel.tsx
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React, { useEffect, useCallback } from 'react';
|
|
2
|
-
import { SafeAreaView } from 'react-native';
|
|
3
|
-
|
|
2
|
+
import { SafeAreaView, StyleSheet } from 'react-native';
|
|
3
|
+
const RTNPinwheel = require('./RTNPinwheelNativeComponent').default;
|
|
4
4
|
import { PinwheelEvents } from './PinwheelEvents';
|
|
5
5
|
import { LinkOptions } from './client-events/client';
|
|
6
6
|
|
|
7
|
+
const styles = StyleSheet.create({
|
|
8
|
+
container: {
|
|
9
|
+
flex: 1,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
7
12
|
const Pinwheel = ({
|
|
8
13
|
linkToken,
|
|
9
14
|
onLogin,
|
|
@@ -66,13 +71,8 @@ const Pinwheel = ({
|
|
|
66
71
|
}, [eventsListener]);
|
|
67
72
|
|
|
68
73
|
return (
|
|
69
|
-
<SafeAreaView style={
|
|
70
|
-
{linkToken &&
|
|
71
|
-
<RTNPinwheel
|
|
72
|
-
style={{ width: '100%', height: '100%' }}
|
|
73
|
-
token={linkToken}
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
74
|
+
<SafeAreaView style={styles.container}>
|
|
75
|
+
{linkToken && <RTNPinwheel style={{ flex: 1 }} token={linkToken} />}
|
|
76
76
|
</SafeAreaView>
|
|
77
77
|
);
|
|
78
78
|
};
|