@layers/amba-react-native 1.0.1 → 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/README.md +16 -18
- package/dist/index.cjs +708 -178
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -49
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +88 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +708 -178
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
# @layers/amba-react-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Amba is the agent-native backend-as-a-service for mobile and web apps. This package is the React Native SDK. Works in both bare React Native and Expo (Go + bare workflow).
|
|
4
|
+
|
|
5
|
+
## What's new in 2.0.0
|
|
6
|
+
|
|
7
|
+
The SDK is now a pure-JS HTTP client — smaller bundles, faster cold starts, no native runtime dependency. The public API (`Amba.configure`, `Amba.auth.*`, `Amba.events.track`, …) is unchanged. Customers upgrading from 1.x do not need any code changes.
|
|
8
|
+
|
|
9
|
+
If you were importing values directly from `@layers/amba-core` through this SDK, install `@layers/amba-core` as a direct dependency. Most apps don't need this.
|
|
4
10
|
|
|
5
11
|
## Install
|
|
6
12
|
|
|
7
13
|
```bash
|
|
8
|
-
|
|
9
|
-
# or:
|
|
14
|
+
npm install @layers/amba-react-native @react-native-async-storage/async-storage
|
|
15
|
+
# or, for Expo:
|
|
10
16
|
npx expo install @layers/amba-react-native @react-native-async-storage/async-storage
|
|
11
17
|
```
|
|
12
18
|
|
|
13
|
-
##
|
|
19
|
+
## Configure + first call
|
|
14
20
|
|
|
15
21
|
```tsx
|
|
16
22
|
import { Amba } from "@layers/amba-react-native";
|
|
17
23
|
|
|
18
24
|
await Amba.configure({ apiKey: "amba_pk_…" });
|
|
19
|
-
|
|
20
25
|
await Amba.auth.signInAnonymously();
|
|
21
26
|
await Amba.events.track("app_opened");
|
|
22
27
|
```
|
|
@@ -24,6 +29,7 @@ await Amba.events.track("app_opened");
|
|
|
24
29
|
## Push registration
|
|
25
30
|
|
|
26
31
|
```tsx
|
|
32
|
+
import { Platform } from "react-native";
|
|
27
33
|
import * as Notifications from "expo-notifications";
|
|
28
34
|
import { Amba } from "@layers/amba-react-native";
|
|
29
35
|
|
|
@@ -31,7 +37,7 @@ const { data: token } = await Notifications.getDevicePushTokenAsync();
|
|
|
31
37
|
await Amba.push.register(token, Platform.OS === "ios" ? "apns" : "fcm");
|
|
32
38
|
```
|
|
33
39
|
|
|
34
|
-
## Sign in with Apple
|
|
40
|
+
## Sign in with Apple / Google
|
|
35
41
|
|
|
36
42
|
```tsx
|
|
37
43
|
import * as AppleAuthentication from "expo-apple-authentication";
|
|
@@ -48,20 +54,12 @@ if (credential.identityToken) {
|
|
|
48
54
|
}
|
|
49
55
|
```
|
|
50
56
|
|
|
51
|
-
|
|
57
|
+
Google works the same way via `expo-auth-session/providers/google` (pass `response.params.id_token` to `Amba.auth.signInWithSocial("google", …)`).
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
import * as Google from "expo-auth-session/providers/google";
|
|
55
|
-
import { Amba } from "@layers/amba-react-native";
|
|
59
|
+
## Docs
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
clientId: "YOUR_GOOGLE_OAUTH_CLIENT_ID",
|
|
59
|
-
});
|
|
60
|
-
if (response?.type === "success") {
|
|
61
|
-
await Amba.auth.signInWithSocial("google", response.params.id_token);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
61
|
+
Full reference: <https://docs.amba.dev/sdk/react-native>.
|
|
64
62
|
|
|
65
63
|
## License
|
|
66
64
|
|
|
67
|
-
MIT
|
|
65
|
+
MIT
|