我们使用的是 firebase 8.2.1 版本。
我们正在使用 React 和 TypeScript 进行开发。
仅当我在 safari 中查看时才会出现该错误。错误是 FirebaseError: Messaging: 此浏览器不支持使用 firebase SDK 所需的 API。(messaging/unsupported-browser)。
我看了下面的文档,只有safari不支持云消息。
我怎么解决这个问题?
https://firebase.google.com/support/guides/environments_js-sdk?hl=ja [在此处输入链接说明] 1
import firebase from 'firebase/app';
import 'firebase/messaging';
import { asyncNotificationToken } from 'apis/asyncNotificationToken';
const firebaseConfig = {
apiKey: '******************',
projectId: '******',
messagingSenderId: '*******',
appId: '********',
};
const VAPID_KEY =
'******************************';
if (firebase.apps.length < 1) {
firebase.initializeApp(firebaseConfig);
}
export const prepareNotification = () => {
firebase
.messaging()
.requestPermission()
.then(() => {
prepareNotificationToken();
})
.catch(() => {
console.log('Unable to …Run Code Online (Sandbox Code Playgroud)