|
@@ -201,11 +201,9 @@ class PushObject:
|
|
@return: bool
|
|
@return: bool
|
|
"""
|
|
"""
|
|
try:
|
|
try:
|
|
- # See documentation on defining a message payload.
|
|
|
|
- cred = credentials.Certificate(
|
|
|
|
- BASE_DIR + '/static/fcm/adcloud-fdf9b-firebase-adminsdk-dcvn1-d53e047cc8.json')
|
|
|
|
- firebase_admin.initialize_app(cred)
|
|
|
|
- push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
|
|
|
|
|
|
+ event_type = str(event_type)
|
|
|
|
+ n_time = str(n_time)
|
|
|
|
+ push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
|
|
'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
|
|
'uid': uid, 'channel': channel
|
|
'uid': uid, 'channel': channel
|
|
}
|
|
}
|
|
@@ -216,14 +214,15 @@ class PushObject:
|
|
message = messaging.Message(
|
|
message = messaging.Message(
|
|
notification=messaging.Notification(
|
|
notification=messaging.Notification(
|
|
title=msg_title,
|
|
title=msg_title,
|
|
- body=msg_text
|
|
|
|
|
|
+ body=msg_text,
|
|
|
|
+ image=image
|
|
),
|
|
),
|
|
data=push_data,
|
|
data=push_data,
|
|
- token=token_val,
|
|
|
|
|
|
+ token=token_val
|
|
)
|
|
)
|
|
# 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, dry_run=True)
|
|
|
|
|
|
+ result = messaging.send(message)
|
|
LOGGER.info('fcm推送结果:{}'.format(result))
|
|
LOGGER.info('fcm推送结果:{}'.format(result))
|
|
return True
|
|
return True
|
|
except Exception as e:
|
|
except Exception as e:
|