Skip to content

Commit

Permalink
Merge pull request #11 from JMTyler/fix-empty-token
Browse files Browse the repository at this point in the history
Fix trying to subscribe with empty FCM token.
  • Loading branch information
JMTyler authored May 6, 2020
2 parents 962bd28 + 6e58677 commit 52ce973
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ const Main = () => {
// chrome.gcm.register([ vapidKey ], (registrationId) => {
// TODO: Debug mode should hook into a separate FCM account purely for testing.
chrome.instanceID.getToken({ authorizedEntity: '710329635775', scope: 'GCM' }, (token) => {
jmtyler.log('registered with gcm', token || chrome.runtime.lastError.message);
jmtyler.log('registered with gcm?', token || chrome.runtime.lastError.message);

if (!token) {
chrome.browserAction.setBadgeText({ text: '!' });
chrome.browserAction.setTitle({ title: 'Failed to connect to notifier service. Try reinstalling the extension.' });
return;
}

// Subscribe our new token to FCM.
jmtyler.request('POST', 'subscribe', { token });
Expand Down

0 comments on commit 52ce973

Please sign in to comment.