Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip devices for check push #548

Merged
merged 1 commit into from
Dec 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ export class StreamChat<
messageID: 'id-of-message',//will error if message does not exist
apnTemplate: '{}', //if app doesn't have apn configured it will error
firebaseTemplate: '{}', //if app doesn't have firebase configured it will error
firebaseDataTemplate: '{}', //if app doesn't have firebase configured it will error
firebaseDataTemplate: '{}', //if app doesn't have firebase configured it will error
skipDevices: true, // skip config/device checks and sending to real devices
}
*/
async testPushSettings(userID: string, data: TestPushDataInput = {}) {
Expand All @@ -443,6 +444,7 @@ export class StreamChat<
...(data.firebaseDataTemplate
? { firebase_data_template: data.firebaseDataTemplate }
: {}),
...(data.skipDevices ? { skip_devices: true } : {}),
});
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ export type TestPushDataInput = {
firebaseDataTemplate?: string;
firebaseTemplate?: string;
messageID?: string;
skipDevices?: boolean;
};

export type TokenOrProvider = null | string | TokenProvider | undefined;
Expand Down
18 changes: 18 additions & 0 deletions test/integration/serverside.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,15 @@ describe('App configs', function () {
await expect(p).to.be.rejectedWith(`User has no enabled devices associated`);
});

it('User has no devices but skips devices', async () => {
const response = await client.testPushSettings(userID, {
apnTemplate: `{"text": "some"}`,
skipDevices: true,
});
expect(response.skip_devices).to.eq(true);
expect(response.rendered_apn_template).to.eq(`{"text": "some"}`);
});

it('App has push disabled', async () => {
const p = client.testPushSettings(userID);
await expect(p).to.be.rejectedWith(
Expand Down Expand Up @@ -1779,6 +1788,15 @@ describe('App configs', function () {
await expect(p).to.be.rejectedWith(`User has no enabled devices associated`);
});

it('User has no devices but skips devices', async () => {
const response = await client.testPushSettings(userID, {
firebaseTemplate: `{"text": "some"}`, // ignored due to v2
skipDevices: true,
});
expect(response.skip_devices).to.eq(true);
expect(response.rendered_message).to.not.eq(undefined);
});

it('App has push disabled', async () => {
const p = client.testPushSettings(userID);
await expect(p).to.be.rejectedWith(
Expand Down