Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 22f1e8a

Browse files
committed
Promisify messaging connect with completion
1 parent 1cc6449 commit 22f1e8a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

firebase.ios.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,32 @@ firebase._processPendingNotifications = function () {
313313
}
314314
};
315315

316+
firebase._messagingConnectWithCompletion = function () {
317+
return new Promise(function (resolve, reject) {
318+
319+
FIRMessaging.messaging().connectWithCompletion(function (error) {
320+
321+
if (error) {
322+
// this is not fatal and it scares the hell out of ppl so not logging it
323+
// console.log("Firebase was unable to connect to FCM. Error: " + error);
324+
return reject(error);
325+
}
326+
327+
firebase._messagingConnected = true;
328+
resolve();
329+
});
330+
331+
});
332+
};
333+
316334
firebase._onTokenRefreshNotification = function (token) {
317335
firebase._pushToken = token;
318336

319337
if (firebase._receivedPushTokenCallback) {
320338
firebase._receivedPushTokenCallback(token);
321339
}
322340

323-
FIRMessaging.messaging().connectWithCompletion(function (error) {
324-
if (error) {
325-
// this is not fatal and it scares the hell out of ppl so not logging it
326-
// console.log("Firebase was unable to connect to FCM. Error: " + error);
327-
} else {
328-
firebase._messagingConnected = true;
329-
}
330-
});
341+
firebase._messagingConnectWithCompletion();
331342
};
332343

333344
firebase._registerForRemoteNotificationsRanThisSession = false;

0 commit comments

Comments
 (0)