Skip to content

Commit 2a23f45

Browse files
committed
Merge branch 'master' of github.com:web-push-libs/pywebpush
2 parents 69059ef + 4919ec1 commit 2a23f45

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pywebpush/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,13 @@ def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
308308
'content-encoding': content_encoding,
309309
})
310310
if gcm_key:
311-
endpoint = 'https://android.googleapis.com/gcm/send'
311+
# guess if it is a legacy GCM project key or actual FCM key
312+
# gcm keys are all about 40 chars (use 100 for confidence),
313+
# fcm keys are 153-175 chars
314+
if len(gcm_key) < 100:
315+
endpoint = 'https://android.googleapis.com/gcm/send'
316+
else:
317+
endpoint = 'https://fcm.googleapis.com/fcm/send'
312318
reg_ids = []
313319
if not reg_id:
314320
reg_id = self.subscription_info['endpoint'].rsplit('/', 1)[-1]

0 commit comments

Comments
 (0)