HMS-Core / hms-push-serverdemo-nodejs

Node.js sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs for your reference or usage.

Home Page:https://developer.huawei.com/consumer/cn/doc/development/HMS-Guides/push-introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

work with FireBase Cloud Functions .

Joseph-Nathan opened this issue · comments

when i add files and attached it with my functions ,
i get 27 error in try to deploy it to the server ,
i want to used hcm from my fb functions if it possible .

`
hcm/auth/auth.ts:25:13 - error TS2564: Property '_token' has no initializer and is not definitely assigned in the constructor.

25 private _token: string;
~~~~~~

hcm/push/message-validator.ts:53:25 - error TS2345: Argument of type 'string[] | undefined' is not assignable to parameter of type 'string[]'.
Type 'undefined' is not assignable to type 'string[]'.

53 validateFieldTarget(message.token, message.topic, message.condition);
~~~~~~~~~~~~~

hcm/push/message-validator.ts:57:34 - error TS2345: Argument of type 'AndroidConfig | undefined' is not assignable to parameter of type 'AndroidConfig'.
Type 'undefined' is not assignable to type 'AndroidConfig'.

57 return validateAndroidConfig(message.android, message.notification);
~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:78:37 - error TS2532: Object is possibly 'undefined'.

78 if (!validator.isNonEmptyString(webPushConfig.notification.title)&&!validator.isNonEmptyString(notification.title)) {
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:78:100 - error TS2532: Object is possibly 'undefined'.

78 if (!validator.isNonEmptyString(webPushConfig.notification.title)&&!validator.isNonEmptyString(notification.title)) {
~~~~~~~~~~~~

hcm/push/message-validator.ts:81:37 - error TS2532: Object is possibly 'undefined'.

81 if (!validator.isNonEmptyString(webPushConfig.notification.body)&&!validator.isNonEmptyString(notification.body)) {
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:81:99 - error TS2532: Object is possibly 'undefined'.

81 if (!validator.isNonEmptyString(webPushConfig.notification.body)&&!validator.isNonEmptyString(notification.body)) {
~~~~~~~~~~~~

hcm/push/message-validator.ts:84:36 - error TS2532: Object is possibly 'undefined'.

84 if (validator.isNonEmptyString(webPushConfig.notification.dir) &&
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:85:6 - error TS2532: Object is possibly 'undefined'.

85 (webPushConfig.notification.dir !== DirAuto &&
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:86:9 - error TS2532: Object is possibly 'undefined'.

86 webPushConfig.notification.dir !== DirLtr &&
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:87:9 - error TS2532: Object is possibly 'undefined'.

87 webPushConfig.notification.dir !== DirRtl)) {
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:90:36 - error TS2532: Object is possibly 'undefined'.

90 if (validator.isNonEmptyString(webPushConfig.headers.urgency) &&
~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:91:6 - error TS2532: Object is possibly 'undefined'.

91 (webPushConfig.headers.urgency !== UrgencyHight &&
~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:92:9 - error TS2532: Object is possibly 'undefined'.

92 webPushConfig.headers.urgency !== UrgencyNormal &&
~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:93:9 - error TS2532: Object is possibly 'undefined'.

93 webPushConfig.headers.urgency !== UrgencyLow&&
~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:94:9 - error TS2532: Object is possibly 'undefined'.

94 webPushConfig.headers.urgency !== UrgencyVeryLow)) {
~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:103:9 - error TS2532: Object is possibly 'undefined'.

103 if (androidConfig.collapse_key < -1 || androidConfig.collapse_key > 100) {
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:103:44 - error TS2532: Object is possibly 'undefined'.

103 if (androidConfig.collapse_key < -1 || androidConfig.collapse_key > 100) {
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:126:40 - error TS2345: Argument of type 'AndroidNotification | undefined' is not assignable to parameter of type 'AndroidNotification'.
Type 'undefined' is not assignable to type 'AndroidNotification'.

126 return validateAndroidNotification(androidConfig.notification, notification);
~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:175:25 - error TS2345: Argument of type 'ClickAction | undefined' is not assignable to parameter of type 'ClickAction'.
Type 'undefined' is not assignable to type 'ClickAction'.

175 validateClickAction(androidNotification.click_action);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/push/message-validator.ts:178:33 - error TS2345: Argument of type 'LightSettings | undefined' is not assignable to parameter of type 'LightSettings'.
Type 'undefined' is not assignable to type 'LightSettings'.

178 return(validateLightSetting(androidNotification.light_settings));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hcm/utils/api-request.ts:21:16 - error TS2307: Cannot find module 'request-promise' or its corresponding type declarations.

21 import rp from "request-promise";
~~~~~~~~~~~~~~~~~

hcm/utils/api-request.ts:26:15 - error TS7006: Parameter 'result' implicitly has an 'any' type.

26 .then(result => {
~~~~~~

hcm/utils/api-request.ts:29:16 - error TS7006: Parameter 'err' implicitly has an 'any' type.

29 .catch(err => {
~~~

hcm/utils/api-request.ts:132:22 - error TS2564: Property 'parseError' has no initializer and is not definitely assigned in the constructor.

132 private readonly parseError: Error;
~~~~~~~~~~

hcm/utils/api-request.ts:169:9 - error TS2322: Type 'undefined' is not assignable to type 'HttpResponse'.

169 return;
~~~~~~~

src/index.ts:3:28 - error TS2306: File '/Users/josephnathan/Documents/andriod/eteaching/firebase/functions/hcm/hcm-app-config.ts' is not a module.

3 import { HmsConfig } from "../hcm/hcm-app-config";
~~~~~~~~~~~~~~~~~~~~~~~

Found 27 errors.

Error: functions predeploy error: Command terminated with non-zero exit code2
`

any idea to access push kit from my firebase cloud functions ?

commented

After connecting to the server with official node.js demo, the client end needs to needs to obtain the push token according to the guide, then you can sending push messages successfully.

@Mike-mei i obtain the push token for client side ,
but wen i use official node.js demo and try to deploy me functions to cloud , i get past errors .
i use typeScript as lang .

commented

Please don't add your own logic, try our official demo directly.

@Mike-mei the error i got from file i don't touch at all ,
like :
`
auth/auth.ts:25:13 - error TS2564: Property '_token' has no initializer and is not definitely assigned in the constructor.

25 private _token: string;


push/message-validator.ts:85:6 - error TS2532: Object is possibly 'undefined'.

85 (webPushConfig.notification.dir !== DirAuto &&

utils/api-request.ts:21:16 - error TS2307: Cannot find module 'request-promise' or its corresponding type declarations.

21 import rp from "request-promise";


`