Skip to content

Commit

Permalink
feat: add xiaomi push provider (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas authored Jan 21, 2022
1 parent 52e9f42 commit 381b0f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ export class StreamChat<
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
huaweiDataTemplate: '{}' //if app doesn't have huawei configured it will error
skipDevices: true, // skip config/device checks and sending to real devices
}
*/
Expand All @@ -710,7 +709,6 @@ export class StreamChat<
...(data.apnTemplate ? { apn_template: data.apnTemplate } : {}),
...(data.firebaseTemplate ? { firebase_template: data.firebaseTemplate } : {}),
...(data.firebaseDataTemplate ? { firebase_data_template: data.firebaseDataTemplate } : {}),
...(data.huaweiDataTemplate ? { huawei_data_template: data.huaweiDataTemplate } : {}),
...(data.skipDevices ? { skip_devices: true } : {}),
});
}
Expand Down
23 changes: 16 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type AppSettingsAPIResponse<CommandType extends string = LiteralStringFor
apn?: APNConfig;
firebase?: FirebaseConfig;
huawei?: HuaweiConfig;
xiaomi?: XiaomiConfig;
};
revoke_tokens_issued_before?: string | null;
search_backend?: 'disabled' | 'elasticsearch' | 'postgres';
Expand Down Expand Up @@ -286,13 +287,16 @@ export type ChannelMemberResponse<UserType = UR> = {

export type CheckPushResponse = APIResponse & {
device_errors?: {
error_message?: string;
provider?: string;
[deviceID: string]: {
error_message?: string;
provider?: string;
};
};
general_errors?: string[];
rendered_apn_template?: string;
rendered_firebase_template?: string;
rendered_huawei_template?: string;
rendered_message?: {};
skip_devides?: boolean;
};

export type CheckSQSResponse = APIResponse & {
Expand Down Expand Up @@ -1443,7 +1447,6 @@ export type AppSettings = {
huawei_config?: {
id: string;
secret: string;
data_template?: string;
};
image_moderation_enabled?: boolean;
image_upload_config?: FileUploadConfig;
Expand All @@ -1457,6 +1460,10 @@ export type AppSettings = {
sqs_url?: string;
webhook_events?: Array<string> | null;
webhook_url?: string;
xiaomi_config?: {
package_name: string;
secret: string;
};
};

export type Attachment<T = UR> = T & {
Expand Down Expand Up @@ -1588,7 +1595,7 @@ export type CheckPushInput<UserType = UR> = {
user_id?: string;
};

export type PushProvider = 'apn' | 'firebase' | 'huawei';
export type PushProvider = 'apn' | 'firebase' | 'huawei' | 'xiaomi';

export type CommandVariants<CommandType extends string = LiteralStringForUnion> =
| 'all'
Expand Down Expand Up @@ -1765,7 +1772,10 @@ export type FirebaseConfig = {
};

export type HuaweiConfig = {
data_template?: string;
enabled?: boolean;
};

export type XiaomiConfig = {
enabled?: boolean;
};

Expand Down Expand Up @@ -1926,7 +1936,6 @@ export type TestPushDataInput = {
apnTemplate?: string;
firebaseDataTemplate?: string;
firebaseTemplate?: string;
huaweiDataTemplate?: string;
messageID?: string;
skipDevices?: boolean;
};
Expand Down

0 comments on commit 381b0f7

Please sign in to comment.