Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get token on iphone #8689

Open
bangluong opened this issue Jan 3, 2025 · 2 comments
Open

Cannot get token on iphone #8689

bangluong opened this issue Jan 3, 2025 · 2 comments

Comments

@bangluong
Copy link

bangluong commented Jan 3, 2025

Operating System

IOS lastest

Environment (if applicable)

N/A

Firebase SDK Version

10.14

Firebase SDK Product(s)

Messaging

Project Tooling

react app and webpack

Detailed Problem Description

after iphone ask permission to push notification, I got error browser not supported.
but I use https://webpushtest.com/,it displays the message normally

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;
};

if (Notification) {
                    const permission = await Notification.requestPermission();
                    if (permission === "granted") {
                        const firebaseToken = await getMessagingToken();
                        await pushToken({
                            variables: {
                                token: firebaseToken
                            }
                        });
                    }
                }
@bangluong bangluong added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jan 3, 2025
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@jbalidiong jbalidiong added api: messaging needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 3, 2025
@DellaBitta
Copy link
Contributor

Hi @bangluong,

Could you clarify if the problem you're encountering is that:

  1. isSupported() returns false, or
  2. isSupported() returns true but then later Messaging doesn't work correctly?

I believe that WebPushTest tests only for a subset of features that Firebase Messaging requires.

Beyond push notifications, Firebase Messaging also requires cookie and IndexedDB support. If either of these features are denied by the user, or if they're disabled due to private browsing or executing within Safari iFrames, then the Firebase Messaging client will not be able to run.

Messaging also requires the browser window to have a fetch implementation, for instance. A full list of isSupported checks can be found here in our public sources.

Could you tell us more about your browser and its current privacy configuration? Are you running in an iFrame in Safari? Do any of the linked checks stand out as something that might not be available in your environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants