@fountispanel/connect-react-native 1.1.0 → 1.4.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/CHANGELOG.md +22 -0
- package/README.md +10 -7
- package/android/build.gradle +35 -17
- package/android/src/main/AndroidManifest.xml +5 -16
- package/build/index.js +1 -126
- package/build/index.web.js +1 -57
- package/ios/FountisConnect.xcframework/Info.plist +44 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine/engine.html +47 -0
- package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64/FountisConnect.framework}/Engine/i18n/ar.json +16 -19
- package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64/FountisConnect.framework}/Engine/i18n/en.json +17 -20
- package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64/FountisConnect.framework}/Engine/i18n/kmr.json +19 -22
- package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/i18n/ku.json +19 -22
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/FountisConnect +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Info.plist +53 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios.swiftinterface +48 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Engine/engine.html +47 -0
- package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Engine}/i18n/ar.json +16 -19
- package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Engine}/i18n/en.json +17 -20
- package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Engine}/i18n/kmr.json +19 -22
- package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/i18n/ku.json +19 -22
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/FountisConnect +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Info.plist +49 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios-simulator.swiftinterface +48 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +48 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/PrivacyInfo.xcprivacy +23 -0
- package/ios/FountisConnectAppDelegateSubscriber.swift +3 -0
- package/ios/FountisConnectModule.swift +3 -0
- package/ios/FountisConnectReactNative.podspec +27 -6
- package/package.json +14 -12
- package/android/connect-sdk/main/assets/fountis-connect/engine.html +0 -47
- package/android/connect-sdk/main/kotlin/org/fountis/connect/ApiClient.kt +0 -179
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Attest.kt +0 -234
- package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisConnect.kt +0 -641
- package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisSurveyActivity.kt +0 -321
- package/android/connect-sdk/main/kotlin/org/fountis/connect/LocalState.kt +0 -143
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Matcher.kt +0 -167
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Models.kt +0 -144
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Notifier.kt +0 -109
- package/android/connect-sdk/main/kotlin/org/fountis/connect/PlayIntegrityAttestor.kt +0 -70
- package/android/connect-sdk/main/kotlin/org/fountis/connect/RequestDeadline.kt +0 -74
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Strings.kt +0 -45
- package/android/connect-sdk/main/kotlin/org/fountis/connect/TokenProviderCall.kt +0 -72
- package/android/connect-sdk/main/res/drawable/fountis_ic_notification.xml +0 -12
- package/android/connect-sdk/main/res/values/fountis_styles.xml +0 -13
- package/android/connect-sdk/main/res/values-v27/fountis_styles.xml +0 -12
- package/build/types.js +0 -1
- package/ios/FountisConnectBundle.swift +0 -15
- package/ios/FountisConnectSDK/ApiClient.swift +0 -137
- package/ios/FountisConnectSDK/Attestation.swift +0 -276
- package/ios/FountisConnectSDK/Engine/engine.html +0 -47
- package/ios/FountisConnectSDK/FountisConnect.swift +0 -441
- package/ios/FountisConnectSDK/LocalState.swift +0 -81
- package/ios/FountisConnectSDK/Matcher.swift +0 -102
- package/ios/FountisConnectSDK/Models.swift +0 -133
- package/ios/FountisConnectSDK/Notifier.swift +0 -63
- package/ios/FountisConnectSDK/RequestDeadline.swift +0 -93
- package/ios/FountisConnectSDK/SheetController.swift +0 -259
- package/ios/FountisConnectSDK/Strings.swift +0 -34
- package/ios/FountisConnectSDK/TokenProviderCall.swift +0 -91
- package/scripts/vendor-native.sh +0 -16
- package/src/index.ts +0 -142
- package/src/index.web.ts +0 -64
- package/src/types.ts +0 -26
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64/FountisConnect.framework}/PrivacyInfo.xcprivacy +0 -0
package/scripts/vendor-native.sh
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Makes the npm tarball self-contained by copying the native SDK sources into this package.
|
|
3
|
-
# Runs on `npm pack` / `npm publish` (prepack). In this repository the podspec copies the Swift SDK itself
|
|
4
|
-
# and Gradle reads ../../android/connect directly, so you do not need this script for development.
|
|
5
|
-
set -e
|
|
6
|
-
HERE="$(cd "$(dirname "$0")/.." && pwd)"
|
|
7
|
-
SDK="$HERE/.."
|
|
8
|
-
|
|
9
|
-
rm -rf "$HERE/ios/FountisConnectSDK" "$HERE/android/connect-sdk"
|
|
10
|
-
mkdir -p "$HERE/ios/FountisConnectSDK" "$HERE/android/connect-sdk"
|
|
11
|
-
cp "$SDK/ios/Sources/FountisConnect/"*.swift "$HERE/ios/FountisConnectSDK/"
|
|
12
|
-
cp "$SDK/ios/Sources/FountisConnect/PrivacyInfo.xcprivacy" "$HERE/ios/FountisConnectSDK/"
|
|
13
|
-
cp -R "$SDK/ios/Sources/FountisConnect/Engine" "$HERE/ios/FountisConnectSDK/Engine"
|
|
14
|
-
cp -R "$SDK/android/connect/src/main" "$HERE/android/connect-sdk/main"
|
|
15
|
-
rm -f "$HERE/android/connect-sdk/main/AndroidManifest.xml" # this package has its own copy of it
|
|
16
|
-
echo "vendored the native SDKs into ios/FountisConnectSDK and android/connect-sdk"
|
package/src/index.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fountispanel/connect-react-native. Public API (same names as the native and web SDKs):
|
|
3
|
-
* start, setUserToken, enableNotifications, show, handlePush, setUserConsent, signOut, onEvent
|
|
4
|
-
*
|
|
5
|
-
* iOS and Android use the native FOUNTIS Connect SDKs (needs an Expo development build or a bare app, not Expo Go).
|
|
6
|
-
* React Native Web wraps the Web SDK (see index.web.ts).
|
|
7
|
-
*/
|
|
8
|
-
import { requireNativeModule } from 'expo-modules-core';
|
|
9
|
-
import type { ConnectEvent, ShowResult, StartOptions, TokenProvider } from './types';
|
|
10
|
-
|
|
11
|
-
export type { ConnectEvent, ShowResult, StartOptions, TokenProvider } from './types';
|
|
12
|
-
|
|
13
|
-
type NativeSubscription = { remove(): void };
|
|
14
|
-
type Native = {
|
|
15
|
-
start(key: string, apiBase: string | null): void;
|
|
16
|
-
enableNotifications(): void;
|
|
17
|
-
show(): Promise<ShowResult>;
|
|
18
|
-
handlePush(data: Record<string, string>): Promise<boolean>;
|
|
19
|
-
setUserConsent(granted: boolean): void;
|
|
20
|
-
signOut(): void;
|
|
21
|
-
setTokenProviderEnabled(enabled: boolean): void;
|
|
22
|
-
resolveToken(id: string, token: string | null): void;
|
|
23
|
-
/** Newer native builds only: tells the SDK the token could not be fetched. Missing on an older binary. */
|
|
24
|
-
rejectToken?(id: string): void;
|
|
25
|
-
addListener(name: string, cb: (payload: any) => void): NativeSubscription;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
let cached: Native | null | undefined;
|
|
29
|
-
/** The native module, or null (with one console warning) when it is missing, for example in Expo Go. */
|
|
30
|
-
function native(): Native | null {
|
|
31
|
-
if (cached !== undefined) return cached;
|
|
32
|
-
try {
|
|
33
|
-
cached = requireNativeModule<Native>('FountisConnect');
|
|
34
|
-
} catch {
|
|
35
|
-
cached = null;
|
|
36
|
-
console.warn(
|
|
37
|
-
'[FountisConnect] The native module was not found. Use an Expo development build or a bare React Native app (not Expo Go), and add the "@fountispanel/connect-react-native" config plugin.',
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return cached;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let provider: TokenProvider | null = null;
|
|
44
|
-
let tokenSub: NativeSubscription | null = null;
|
|
45
|
-
|
|
46
|
-
function ensureTokenListener(n: Native) {
|
|
47
|
-
if (tokenSub) return;
|
|
48
|
-
// The native SDK asks for a token when it needs one. We answer from the function the app gave us.
|
|
49
|
-
tokenSub = n.addListener('onTokenRequest', async (e: { id: string }) => {
|
|
50
|
-
let token: string | null;
|
|
51
|
-
try {
|
|
52
|
-
token = (await provider?.()) ?? null;
|
|
53
|
-
} catch {
|
|
54
|
-
// A provider that throws could not get a token (a failed request, say). That is not "signed out", so never
|
|
55
|
-
// answer null here: null makes the SDK offer guest studies to someone who is signed in. Report the failure instead.
|
|
56
|
-
// An older native binary has no rejectToken: nothing is sent, the request times out as before and is read as null
|
|
57
|
-
// (the old behaviour). Rebuild the native app to get the fix.
|
|
58
|
-
if (typeof n.rejectToken === 'function') n.rejectToken(e.id);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
n.resolveToken(e.id, token);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Starts the SDK. Call once, early. Safe to call again. */
|
|
66
|
-
export function start(options: StartOptions): void {
|
|
67
|
-
try {
|
|
68
|
-
native()?.start(options.key, options.apiBase ?? null);
|
|
69
|
-
} catch {}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Gives the SDK a way to get the signed user token from your server. The function returns the token when someone is
|
|
74
|
-
* signed in and `null` only when nobody is. Throw (or reject) when you cannot get a token, for example when your token
|
|
75
|
-
* endpoint fails: nothing is shown then, and the person is not treated as a guest. No answer within 10 seconds also
|
|
76
|
-
* counts as a failure.
|
|
77
|
-
*/
|
|
78
|
-
export function setUserToken(tokenProvider: TokenProvider | string | null): void {
|
|
79
|
-
try {
|
|
80
|
-
provider = typeof tokenProvider === 'function' ? tokenProvider : () => tokenProvider;
|
|
81
|
-
const n = native();
|
|
82
|
-
if (!n) return;
|
|
83
|
-
ensureTokenListener(n);
|
|
84
|
-
n.setTokenProviderEnabled(true);
|
|
85
|
-
} catch {}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Turns on the background check and asks for the notification permission. One notification a day at most. */
|
|
89
|
-
export function enableNotifications(): void {
|
|
90
|
-
try {
|
|
91
|
-
native()?.enableNotifications();
|
|
92
|
-
} catch {}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Looks for a matching study and shows it full screen. Resolves when the person is done. */
|
|
96
|
-
export async function show(): Promise<ShowResult> {
|
|
97
|
-
try {
|
|
98
|
-
return (await native()?.show()) ?? 'noFill';
|
|
99
|
-
} catch {
|
|
100
|
-
return 'noFill';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Call from your push handler with the message data. Resolves `true` if it was a FOUNTIS push (it has a `fountis` key). */
|
|
105
|
-
export async function handlePush(data: Record<string, unknown>): Promise<boolean> {
|
|
106
|
-
try {
|
|
107
|
-
const strings: Record<string, string> = {};
|
|
108
|
-
for (const [k, v] of Object.entries(data ?? {})) strings[k] = typeof v === 'string' ? v : String(v);
|
|
109
|
-
return (await native()?.handlePush(strings)) ?? false;
|
|
110
|
-
} catch {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** Pass the person's consent to be offered studies. Default: true. */
|
|
116
|
-
export function setUserConsent(granted: boolean): void {
|
|
117
|
-
try {
|
|
118
|
-
native()?.setUserConsent(granted);
|
|
119
|
-
} catch {}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Forget the signed-in person: removes their local state and pending notifications. */
|
|
123
|
-
export function signOut(): void {
|
|
124
|
-
try {
|
|
125
|
-
native()?.signOut();
|
|
126
|
-
} catch {}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** Listens to anonymous lifecycle events. Returns a function that removes the listener. */
|
|
130
|
-
export function onEvent(listener: (event: ConnectEvent) => void): () => void {
|
|
131
|
-
const n = native();
|
|
132
|
-
if (!n) return () => {};
|
|
133
|
-
const sub = n.addListener('onFountisEvent', (e: ConnectEvent) => {
|
|
134
|
-
try {
|
|
135
|
-
listener(e);
|
|
136
|
-
} catch {}
|
|
137
|
-
});
|
|
138
|
-
return () => sub.remove();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const FountisConnect = { start, setUserToken, enableNotifications, show, handlePush, setUserConsent, signOut, onEvent };
|
|
142
|
-
export default FountisConnect;
|
package/src/index.web.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React Native Web: wraps the Web SDK (`@fountispanel/connect`). Same API as the native build.
|
|
3
|
-
* Notifications are an in-page invitation only, and there are no push messages on the web.
|
|
4
|
-
*/
|
|
5
|
-
import * as web from '@fountispanel/connect';
|
|
6
|
-
import type { ConnectEvent, ShowResult, StartOptions, TokenProvider } from './types';
|
|
7
|
-
|
|
8
|
-
export type { ConnectEvent, ShowResult, StartOptions, TokenProvider } from './types';
|
|
9
|
-
|
|
10
|
-
export function start(options: StartOptions): void {
|
|
11
|
-
try {
|
|
12
|
-
web.start({ key: options.key, apiBase: options.apiBase, engineUrl: options.engineUrl });
|
|
13
|
-
} catch {}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function setUserToken(tokenProvider: TokenProvider | string | null): void {
|
|
17
|
-
try {
|
|
18
|
-
web.setUserToken(
|
|
19
|
-
typeof tokenProvider === 'function' ? async () => (await tokenProvider()) ?? null : (tokenProvider ?? null),
|
|
20
|
-
);
|
|
21
|
-
} catch {}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function enableNotifications(): void {
|
|
25
|
-
try {
|
|
26
|
-
web.enableNotifications();
|
|
27
|
-
} catch {}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function show(): Promise<ShowResult> {
|
|
31
|
-
try {
|
|
32
|
-
return await web.show();
|
|
33
|
-
} catch {
|
|
34
|
-
return 'noFill';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The web has no push messages. */
|
|
39
|
-
export async function handlePush(_data: Record<string, unknown>): Promise<boolean> {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function setUserConsent(granted: boolean): void {
|
|
44
|
-
try {
|
|
45
|
-
web.setUserConsent(granted);
|
|
46
|
-
} catch {}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function signOut(): void {
|
|
50
|
-
try {
|
|
51
|
-
web.signOut();
|
|
52
|
-
} catch {}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function onEvent(listener: (event: ConnectEvent) => void): () => void {
|
|
56
|
-
try {
|
|
57
|
-
return web.onEvent((e) => listener(e as ConnectEvent));
|
|
58
|
-
} catch {
|
|
59
|
-
return () => {};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const FountisConnect = { start, setUserToken, enableNotifications, show, handlePush, setUserConsent, signOut, onEvent };
|
|
64
|
-
export default FountisConnect;
|
package/src/types.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** What `show()` resolves to. Every failure is `noFill`; the SDK never throws into your app. */
|
|
2
|
-
export type ShowResult = 'noFill' | 'dismissed' | 'completed';
|
|
3
|
-
|
|
4
|
-
/** Anonymous lifecycle event. Carries no survey titles, topics or answers. */
|
|
5
|
-
export type ConnectEvent = {
|
|
6
|
-
type: 'shown' | 'started' | 'dismissed' | 'completed' | 'noFill' | 'notified';
|
|
7
|
-
offerId?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Returns the signed user token from your server when someone is signed in.
|
|
12
|
-
* Return `null` (or `undefined`) only when nobody is signed in: the SDK then offers guest studies, if your app allows guests.
|
|
13
|
-
* Throw (or reject) when you cannot get a token, for example when your token endpoint fails: nothing is shown
|
|
14
|
-
* (`noFill`) and the person is never treated as a guest. No answer within 10 seconds also counts as a failure.
|
|
15
|
-
* Called on demand; the SDK does not keep the token longer than one check.
|
|
16
|
-
*/
|
|
17
|
-
export type TokenProvider = () => Promise<string | null | undefined> | string | null | undefined;
|
|
18
|
-
|
|
19
|
-
export type StartOptions = {
|
|
20
|
-
/** Your publishable key, `pk_test_...` or `pk_live_...`. */
|
|
21
|
-
key: string;
|
|
22
|
-
/** Override the API base URL. Defaults to the FOUNTIS production API. */
|
|
23
|
-
apiBase?: string;
|
|
24
|
-
/** Web only: override the URL of the hosted survey engine. */
|
|
25
|
-
engineUrl?: string;
|
|
26
|
-
};
|