Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 5 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1679,88 +1679,12 @@ setBiometricsAuthenticationStatus: ({enable: boolean}) => Promise<void>;

<kbd>App version >= TBD</kbd>

Enable/configure Family Locator SDK. Wrapper for `sdk.setConfig(config)`.
Enable/configure Family Locator SDK. Wrapper for `sdk.setConfig(config)`. See
SDK type `LocatorConfig`:
https://datamob.gitbook.io/doc-locator/TQfkVhcPsZiXIvXxq8Bv/english/service#id-4.5.1-setconfig-config-locatorconfig-void

```ts
setupLocatorSdkConfig: (config: LocatorSdkConfig) => Promise<void>;
```

#### Types

```ts
export type LocatorSdkConfig = {
license: string;
sdkVersion: string;
osPlatform: string;
api: {
token: string;
certUrl?: string;
scopesUrl?: string;
tokenUrl?: string;
configUrl?: string;
groupsUrl?: string;
featuresUrl?: string;
geofencesUrl?: string;
};
mqtt: {
clientId?: string;
broker?: string;
port?: string;
username?: string;
};
process: {
retryPolicy?: {
maxRetries?: number;
baseDelayMs?: number;
backoffFactor?: number;
};
offlineRetentionDays?: number;
foregroundServiceNotification?: {
title?: string;
message?: string;
};
};
battery?: {
events?: Array<{
name: string;
min: number;
max: number;
interval: number;
charging: boolean;
powerMode: Array<'normal' | 'power_saver' | 'super_saver'>;
}>;
};
motion?: {
sensitivity?: number;
};
collect?: {
collectIntervalMillis?: number;
sendIntervalMillis?: number;
minDisplacementMeters?: number;
maxTravelDistanceMeters?: number;
highAccuracy?: boolean;
maxBatchSize?: number;
};
audioRecord?: {
recordsCount: number;
durationSeconds: number;
retryCount: number;
intervalSeconds: number;
audioServiceNotification?: {
title?: string;
message?: string;
};
};
revision?: number;
createdAt?: number;
updatedAt?: number;
};
```

#### Example

```ts
setupLocatorSdkConfig({license: 'xxx', sdkVersion: '2.0.1'});
setupLocatorSdkConfig: (config: Record<string, unknown>) => Promise<void>;
```

#### Error cases
Expand Down Expand Up @@ -1865,7 +1789,7 @@ Get current SDK config. Wrapper for `getConfig`. See SDK type `LocatorConfig`:
https://datamob.gitbook.io/doc-locator/TQfkVhcPsZiXIvXxq8Bv/english/service#id-4.4.1-getconfig-locatorconfig

```ts
getLocatorSdkConfig: () => Promise<{config: LocatorSdkConfig | null}>;
getLocatorSdkConfig: () => Promise<{config: Record<string, unknown> | null}>;
```

### requestPermissionLocation
Expand Down
1 change: 0 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export {

export {
type LocatorSdkMode,
type LocatorSdkConfig,
setupLocatorSdkConfig,
getLocatorSdkState,
setLocatorSdkMode,
Expand Down
72 changes: 2 additions & 70 deletions src/family-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,8 @@ import {postMessageToNativeApp} from './post-message';

export type LocatorSdkMode = string;

export type LocatorSdkConfig = {
license: string;
sdkVersion: string;
osPlatform: string;
api: {
token: string;
certUrl?: string;
scopesUrl?: string;
tokenUrl?: string;
configUrl?: string;
groupsUrl?: string;
featuresUrl?: string;
geofencesUrl?: string;
};
mqtt: {
clientId?: string;
broker?: string;
port?: string;
username?: string;
};
process: {
retryPolicy?: {
maxRetries?: number;
baseDelayMs?: number;
backoffFactor?: number;
};
offlineRetentionDays?: number;
foregroundServiceNotification?: {
title?: string;
message?: string;
};
};
battery?: {
events?: Array<{
name: string;
min: number;
max: number;
interval: number;
charging: boolean;
powerMode: Array<'normal' | 'power_saver' | 'super_saver'>;
}>;
};
motion?: {
sensitivity?: number;
};
collect?: {
collectIntervalMillis?: number;
sendIntervalMillis?: number;
minDisplacementMeters?: number;
maxTravelDistanceMeters?: number;
highAccuracy?: boolean;
maxBatchSize?: number;
};
audioRecord?: {
recordsCount: number;
durationSeconds: number;
retryCount: number;
intervalSeconds: number;
audioServiceNotification?: {
title?: string;
message?: string;
};
};
revision?: number;
createdAt?: number;
updatedAt?: number;
};

export const setupLocatorSdkConfig = (
config: LocatorSdkConfig,
config: Record<string, unknown>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to maintain an object definition here that will change depending on the SDK version. We prefer to just link to the SDK documentation and accept any JSON object.

I changed it to Record<string, unknown>, but if you prefer another generic type, I will change it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

): Promise<void> =>
postMessageToNativeApp({
type: 'SETUP_LOCATOR_SDK_CONFIG',
Expand Down Expand Up @@ -116,7 +48,7 @@ export const getLocatorSdkMode = (): Promise<{
}> => postMessageToNativeApp({type: 'GET_LOCATOR_SDK_MODE'});

export const getLocatorSdkConfig = (): Promise<{
config: LocatorSdkConfig | null;
config: Record<string, unknown> | null;
}> =>
postMessageToNativeApp({
type: 'GET_LOCATOR_SDK_CONFIG',
Expand Down
3 changes: 1 addition & 2 deletions src/post-message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {getId} from './message-id';
import type {LocatorSdkConfig} from './family-locator';

/**
* There are two possible kind of messages we can receive from native app:
Expand Down Expand Up @@ -544,7 +543,7 @@ export type ResponsesFromNativeApp = {
GET_LOCATOR_SDK_CONFIG: {
type: 'GET_LOCATOR_SDK_CONFIG';
id: string;
payload: {config: LocatorSdkConfig | null};
payload: {config: Record<string, unknown> | null};
};

REQUEST_ALLOWME_BIOMETRICS: {
Expand Down
Loading