diff --git a/app/definitions/rest/v1/push.ts b/app/definitions/rest/v1/push.ts index 0e0c70ebd..f00f737bb 100644 --- a/app/definitions/rest/v1/push.ts +++ b/app/definitions/rest/v1/push.ts @@ -18,4 +18,7 @@ export type PushEndpoints = { 'push.info': { GET: () => TPushInfo; }; + 'push.test': { + POST: () => { tokensCount: number }; + }; }; diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index f6828f132..62fa09911 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -828,5 +828,6 @@ "Message_roomname": "Message {{roomName}}", "Microphone_access_needed_to_record_audio": "Microphone access needed to record audio", "Go_to_your_device_settings_and_allow_microphone": "Go to your device settings and allow microphone access for Rocket.Chat", - "Check_again": "Check again" + "Check_again": "Check again", + "error-no-tokens-for-this-user": "There are no tokens for this user" } \ No newline at end of file diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index c6d923f0a..577654cf4 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -820,5 +820,6 @@ "Go_to_your_device_settings_and_allow_microphone": "Vá para as configurações do seu dispositivo e permita o acesso ao microfone pelo aplicativo Rocket.Chat", "In_app_message_notifications": "Notificações de mensagens in-app", "Vibrate": "Vibrar", - "Check_again": "Verificar novamente" + "Check_again": "Verificar novamente", + "error-no-tokens-for-this-user": "Não existem tokens para este usuário" } \ No newline at end of file diff --git a/app/lib/services/restApi.ts b/app/lib/services/restApi.ts index 25bda5d30..4451f17fc 100644 --- a/app/lib/services/restApi.ts +++ b/app/lib/services/restApi.ts @@ -905,7 +905,7 @@ export const removePushToken = (): Promise => { return Promise.resolve(); }; -export const pushTest = (): Promise<{ message: string; params: number[] }> => sdk.methodCallWrapper('push_test'); +export const pushTest = () => sdk.post('push.test'); // RC 6.5.0 export const pushInfo = () => sdk.get('push.info'); diff --git a/app/views/PushTroubleshootView/index.tsx b/app/views/PushTroubleshootView/index.tsx index 96787658d..280d5f02c 100644 --- a/app/views/PushTroubleshootView/index.tsx +++ b/app/views/PushTroubleshootView/index.tsx @@ -82,9 +82,11 @@ const PushTroubleshootView = ({ navigation }: IPushTroubleshootViewProps): JSX.E let message = ''; try { const result = await Services.pushTest(); - message = I18n.t('Your_push_was_sent_to_s_devices', { s: result.params[0] }); + if (result.success) { + message = I18n.t('Your_push_was_sent_to_s_devices', { s: result.tokensCount }); + } } catch (error: any) { - message = I18n.isTranslated(error?.error) ? I18n.t(error?.error) : error?.message; + message = I18n.isTranslated(error?.data?.errorType) ? I18n.t(error?.data?.errorType) : error?.data?.error; } finally { Alert.alert(I18n.t('Test_push_notification'), message); }