|
@@ -16,6 +16,7 @@ import firebase_admin
|
|
|
import jpush
|
|
import jpush
|
|
|
import requests
|
|
import requests
|
|
|
from firebase_admin import messaging
|
|
from firebase_admin import messaging
|
|
|
|
|
+from firebase_admin.messaging import UnregisteredError
|
|
|
from pyfcm import FCMNotification
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
|
|
from AnsjerPush.config import APP_BUNDLE_DICT, APNS_MODE, BASE_DIR, APNS_CONFIG, FCM_CONFIG, JPUSH_CONFIG, XMPUSH_CONFIG \
|
|
from AnsjerPush.config import APP_BUNDLE_DICT, APNS_MODE, BASE_DIR, APNS_CONFIG, FCM_CONFIG, JPUSH_CONFIG, XMPUSH_CONFIG \
|
|
@@ -242,10 +243,14 @@ class PushObject:
|
|
|
# Send a message to the device corresponding to the provided
|
|
# Send a message to the device corresponding to the provided
|
|
|
# registration token.
|
|
# registration token.
|
|
|
result = messaging.send(message)
|
|
result = messaging.send(message)
|
|
|
- LOGGER.info('uid:{}fcm推送结果:{}'.format(uid, result))
|
|
|
|
|
|
|
+ LOGGER.info('uid:{} fcm推送结果:{}'.format(uid, result))
|
|
|
return True
|
|
return True
|
|
|
|
|
+ except UnregisteredError as e:
|
|
|
|
|
+ LOGGER.info('uid:{},token:{},fcm推送异常UnregisteredError:{}'.format(uid, token_val, repr(e)))
|
|
|
|
|
+ # 删除失效token数据
|
|
|
|
|
+ UidPushModel.objects.filter(uid_set__uid=uid, token_val=token_val).delete()
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
- LOGGER.info('uid:{}fcm推送异常:{}'.format(uid, repr(e)))
|
|
|
|
|
|
|
+ LOGGER.info('uid:{} fcm推送异常:{}'.format(uid, repr(e)))
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|