olucurious / PyFCM

Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)
http://olucurious.github.io/PyFCM/
MIT License
802 stars 204 forks source link

push notification doesn't work in pyfcm 2.0.2 #333

Closed almaz1213 closed 2 months ago

almaz1213 commented 2 months ago

we have error !

steps:

  1. updated pyfcm to 2.0.2
  2. generated new fcmServiceAccKey.json in the Firebase console
  3. our android app got new fcm token for a user

test code on the server side:

from pyfcm import FCMNotification

fcm = FCMNotification(service_account_file=<absolute path to>fcmServiceAccKey.json', project_id='iolmsg-filestore')

res = fcm.notify(<user token from step 3>, 'title', 'text')

print(res)

result: 1

use to use method .notify_single_device but now FCMNotification has no this method

wkpark commented 2 months ago

you can check your serviceAccount.json file first.

{
  "type": "service_account",
  "project_id": "XXXX-YYYY",
  "private_key_id": "abced...",
  "private_key": "-----BEGIN PRIVATE KEY-----...",
  ...
}
almaz1213 commented 2 months ago

@wkpark json generated by farebase console and the json file is valid json format.

how can my checks fix the error?

wkpark commented 2 months ago

@wkpark json generated by farebase console and the json file is valid json format.

how can my checks fix the error?

I can confirm that with an invalid fcm_token, I've got the same error as yours.

params_list =  [{'fcm_token': 'aaaa', 'notification_title': 'Hello World', 'notification_body': 'pyfcm 2.0.2 test from development server. thanks'}] # for async_notify_multiple_devices(params_list=params_list) args, or notify(**params_list[0])

[{'error': {'code': 400, 'message': 'The registration token is not a valid FCM registration token', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.firebase.fcm.v1.FcmError', 'errorCode': 'INVALID_ARGUMENT'}]}}]
almaz1213 commented 2 months ago
  1. on the machine with pyfcm 1.5.4 works fine with the same fcm_token. so, it means the problem is not with fcm_token
  2. from firebase console works also

problem in pyfcm 2.0.2 with the new fcm implementation

almaz1213 commented 2 months ago

i think you should check scopes parameter.....

almaz1213 commented 2 months ago

request using curl response with the same error. so, it's not in pyfcm end