@pinwheel/react-native-pinwheel 3.7.0 → 3.7.1
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/RNPinwheelSDK.podspec +2 -0
- package/android/src/main/java/com/rtnpinwheel/Pinwheel.kt +1 -1
- package/ios/PWPinwheelWrapperVC.swift +97 -0
- package/ios/RTNPinwheelView.mm +4 -4
- package/package.json +3 -2
- package/src/Pinwheel.d.ts +1 -1
- package/src/RTNPinwheelNativeComponent.d.ts +1 -0
- package/src/client-events/client.d.ts +1 -0
package/RNPinwheelSDK.podspec
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import PinwheelSDK
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
@objc public protocol PWPinwheelWrapperDelegate {
|
|
6
|
+
func onEvent(name: String, event: [String: AnyObject])
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@objcMembers
|
|
10
|
+
public final class PWPinwheelWrapperVC: UIViewController {
|
|
11
|
+
private let token: String
|
|
12
|
+
private let delegateBridge: PWPinwheelWrapperDelegate
|
|
13
|
+
|
|
14
|
+
private let useSecureOrigin: Bool
|
|
15
|
+
private let useDarkMode: Bool
|
|
16
|
+
private let sdk: String
|
|
17
|
+
private let version: String
|
|
18
|
+
|
|
19
|
+
private var pinwheelVC: PinwheelViewController?
|
|
20
|
+
|
|
21
|
+
public init(
|
|
22
|
+
token: String,
|
|
23
|
+
delegate: PWPinwheelWrapperDelegate,
|
|
24
|
+
sdk: String,
|
|
25
|
+
version: String,
|
|
26
|
+
useSecureOrigin: Bool,
|
|
27
|
+
useDarkMode: Bool = false,
|
|
28
|
+
useAppBoundDomains: Bool = false,
|
|
29
|
+
useAppBoundDomainsForNativeLink: Bool = false
|
|
30
|
+
) {
|
|
31
|
+
self.token = token
|
|
32
|
+
self.delegateBridge = delegate
|
|
33
|
+
self.sdk = sdk
|
|
34
|
+
self.version = version
|
|
35
|
+
self.useSecureOrigin = useSecureOrigin
|
|
36
|
+
self.useDarkMode = useDarkMode
|
|
37
|
+
super.init(nibName: nil, bundle: nil)
|
|
38
|
+
|
|
39
|
+
var config = PinwheelConfig(mode: .sandbox, environment: .production, sdk: sdk, version: version)
|
|
40
|
+
config.useSecureOrigin = useSecureOrigin
|
|
41
|
+
|
|
42
|
+
let vc = PinwheelViewController(
|
|
43
|
+
token: token,
|
|
44
|
+
delegate: self,
|
|
45
|
+
config: config,
|
|
46
|
+
useDarkMode: useDarkMode,
|
|
47
|
+
useAppBoundDomains: useAppBoundDomains,
|
|
48
|
+
useAppBoundDomainsForNativeLink: useAppBoundDomainsForNativeLink
|
|
49
|
+
)
|
|
50
|
+
self.pinwheelVC = vc
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public required init?(coder: NSCoder) {
|
|
54
|
+
nil
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public override func viewDidLoad() {
|
|
58
|
+
super.viewDidLoad()
|
|
59
|
+
guard let pinwheelVC else { return }
|
|
60
|
+
|
|
61
|
+
addChild(pinwheelVC)
|
|
62
|
+
view.addSubview(pinwheelVC.view)
|
|
63
|
+
pinwheelVC.didMove(toParent: self)
|
|
64
|
+
|
|
65
|
+
pinwheelVC.view.translatesAutoresizingMaskIntoConstraints = false
|
|
66
|
+
NSLayoutConstraint.activate([
|
|
67
|
+
pinwheelVC.view.topAnchor.constraint(equalTo: view.topAnchor),
|
|
68
|
+
pinwheelVC.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
|
69
|
+
pinwheelVC.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
|
70
|
+
pinwheelVC.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
|
71
|
+
])
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// MARK: - PinwheelDelegate
|
|
76
|
+
|
|
77
|
+
extension PWPinwheelWrapperVC: PinwheelDelegate {
|
|
78
|
+
public func onEvent(name: PinwheelEventType, event: PinwheelEventPayload?) {
|
|
79
|
+
var payload: [String: AnyObject] = [:]
|
|
80
|
+
|
|
81
|
+
if let event {
|
|
82
|
+
do {
|
|
83
|
+
let json = try event.jsonString()
|
|
84
|
+
if let jsonData = json.data(using: .utf8) {
|
|
85
|
+
let jsonObject = try JSONSerialization.jsonObject(with: jsonData)
|
|
86
|
+
if let jsonDictionary = jsonObject as? [String: AnyObject] {
|
|
87
|
+
payload = jsonDictionary
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// Best-effort payload serialization; still forward event name.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
delegateBridge.onEvent(name: name.rawValue, event: payload)
|
|
96
|
+
}
|
|
97
|
+
}
|
package/ios/RTNPinwheelView.mm
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import "RCTFabricComponentsPlugins.h"
|
|
11
11
|
#import "RTNPinwheelEvents.h"
|
|
12
|
-
#import
|
|
12
|
+
#import "RNPinwheelSDK-Swift.h"
|
|
13
13
|
|
|
14
14
|
using namespace facebook::react;
|
|
15
15
|
|
|
@@ -75,7 +75,7 @@ using namespace facebook::react;
|
|
|
75
75
|
[[PWPinwheelWrapperVC alloc] initWithToken:self.token
|
|
76
76
|
delegate:self
|
|
77
77
|
sdk:@"react native"
|
|
78
|
-
version:@"3.7.
|
|
78
|
+
version:@"3.7.1"
|
|
79
79
|
useSecureOrigin:self.useSecureOrigin
|
|
80
80
|
useDarkMode:self.useDarkMode
|
|
81
81
|
useAppBoundDomains:NO
|
|
@@ -187,7 +187,7 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
|
|
|
187
187
|
|
|
188
188
|
#import "RTNPinwheelEvents.h"
|
|
189
189
|
#import "RTNPinwheelView.h"
|
|
190
|
-
#import
|
|
190
|
+
#import "RNPinwheelSDK-Swift.h"
|
|
191
191
|
|
|
192
192
|
@implementation RTNPinwheelView
|
|
193
193
|
|
|
@@ -244,7 +244,7 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
|
|
|
244
244
|
[[PWPinwheelWrapperVC alloc] initWithToken:self.token
|
|
245
245
|
delegate:self
|
|
246
246
|
sdk:@"react native"
|
|
247
|
-
version:@"3.7.
|
|
247
|
+
version:@"3.7.1"
|
|
248
248
|
useSecureOrigin:self.useSecureOrigin
|
|
249
249
|
useDarkMode:self.useDarkMode
|
|
250
250
|
useAppBoundDomains:NO
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinwheel/react-native-pinwheel",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsc",
|
|
25
|
-
"dev": "./scripts/dev_expo.sh"
|
|
25
|
+
"dev": "./scripts/dev_expo.sh",
|
|
26
|
+
"dev:bare": "./scripts/dev_bare.sh"
|
|
26
27
|
},
|
|
27
28
|
"author": "Pinwheel",
|
|
28
29
|
"license": "MIT",
|
package/src/Pinwheel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LinkOptions } from './client-events/client';
|
|
3
|
-
declare const Pinwheel: ({ linkToken, onLogin, onLoginAttempt, onSuccess, onError, onExit, onEvent, handleInsets, useDarkMode, }: LinkOptions & {
|
|
3
|
+
declare const Pinwheel: ({ linkToken, onLogin, onLoginAttempt, onSuccess, onError, onExit, onEvent, handleInsets, useDarkMode, useSecureOrigin, }: LinkOptions & {
|
|
4
4
|
handleInsets?: boolean;
|
|
5
5
|
useDarkMode?: boolean;
|
|
6
6
|
}) => React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LoginEventPayload, SuccessEventPayload, EventHandler, ErrorEventPayload, LoginAttemptEventPayload } from './registry/v3';
|
|
2
2
|
export type LinkOptions = {
|
|
3
3
|
linkToken: string;
|
|
4
|
+
useSecureOrigin?: boolean;
|
|
4
5
|
onLogin?: (payload: LoginEventPayload) => void;
|
|
5
6
|
onLoginAttempt?: (payload: LoginAttemptEventPayload) => void;
|
|
6
7
|
onSuccess?: (payload: SuccessEventPayload) => void;
|