Closed
Description
Operating System
IOS 18.3
Environment (if applicable)
safari
Firebase SDK Version
10.14.0
Firebase SDK Product(s)
Messaging
Project Tooling
reactJS and webpack
Detailed Problem Description
I create requestPermission and get token after login.
after iphone ask permission to push notification, I got error browser not supported.
but if I logout and login again it get token successfully
Steps and code to reproduce issue
here is my code:
const messaging = (async () => {
const isSupportedBrowser = await isSupported();
if (isSupportedBrowser) {
return getMessaging(firebase);
}
return null;
})
export const getMessagingToken = async () => {
let currentToken = "";
const messagingResolve = await messaging();
if (!messagingResolve) return;
try {
currentToken = await getToken(messagingResolve, {
vapidKey: process.env.FIREBASE_VAPIDKEY
});
} catch (error) {
console.log("An error occurred while retrieving token. ", error);
}
return currentToken;
};
at login function, I add this code:
if (Notification) {
const permission = await Notification.requestPermission();
if (permission === "granted") {
const firebaseToken = await getMessagingToken();
await pushToken({
variables: {
token: firebaseToken
}
});
}
}