Skip to content

Commit

Permalink
feat(datamob): unregisterDatamobDeviceAdmin method (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel authored Dec 16, 2024
1 parent 776aab3 commit 634abb9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,14 @@ requestDatamobDeviceAdmin: () => Promise<{isAdmin: boolean}>;
https://github.com/user-attachments/assets/28095f42-76db-4ac2-9586-e350acef7e1d
### unregisterDatamobDeviceAdmin
Method to unregister the application as a system management application.
```ts
unregisterDatamobDeviceAdmin: () => Promise<void>;
```
### registerDatamobUser
<kbd>App version >=25.0</kbd>
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export {
registerDatamobUser,
requestDatamobDeviceAdmin,
validateDatamobRequirements,
unregisterDatamobDeviceAdmin,
} from './src/datamob';

export {
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/datamob-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
registerDatamobUser,
requestDatamobDeviceAdmin,
unregisterDatamobDeviceAdmin,
validateDatamobRequirements,
} from '../datamob';
import {createFakeAndroidPostMessage} from './fake-post-message';
Expand Down Expand Up @@ -104,3 +105,18 @@ test('validateDatamobRequirements', async () => {
},
});
});

test('unregisterDatamobDeviceAdmin', async () => {
createFakeAndroidPostMessage({
checkMessage: (msg) => {
expect(msg.type).toBe('UNREGISTER_DATAMOB_DEVICE_ADMIN');
},
getResponse: (msg) => ({
type: 'UNREGISTER_DATAMOB_DEVICE_ADMIN',
id: msg.id,
}),
});

const res = await unregisterDatamobDeviceAdmin();
expect(res).toBeUndefined();
});
3 changes: 3 additions & 0 deletions src/datamob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ export const validateDatamobRequirements = ({
type: 'VALIDATE_DATAMOB_REQUIREMENTS',
payload: {phoneNumber, tokenPassword},
}).then(({requirements}) => ({requirements}));

export const unregisterDatamobDeviceAdmin = (): Promise<void> =>
postMessageToNativeApp({type: 'UNREGISTER_DATAMOB_DEVICE_ADMIN'});
5 changes: 5 additions & 0 deletions src/post-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ export type ResponsesFromNativeApp = {
};
};
};
UNREGISTER_DATAMOB_DEVICE_ADMIN: {
type: 'UNREGISTER_DATAMOB_DEVICE_ADMIN';
id: string;
payload: void;
};
DISPLAY_QUALTRICS_INTERCEPT: {
type: 'DISPLAY_QUALTRICS_INTERCEPT';
id: string;
Expand Down

0 comments on commit 634abb9

Please sign in to comment.