gpt4 book ai didi

expo - 由于 : Lcom/google/firebase/iid/FirebaseInstanceId; 的解析失败,无法在 Expo Notification 中获取 expoToken

转载 作者:行者123 更新时间:2023-12-05 06:00:05 25 4
gpt4 key购买 nike

下午好,希望你们今天过得愉快,我已经在使用 expo bare 工作流程构建一些应用程序,并且需要使用 Expo Notification,我正在按照来自 expo notification documentations 的所有说明进行操作, 和 fcm configurations , 至 setup firebase ,但是,当我尝试获取 expoToken 时,我收到了这个警告,看起来像这样:

Error: Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId;

而且我已经确定我的包名和我在firebase中注册的包名是一样的,你们能帮帮我吗?请 :slight_smile:

这是附加信息:

Getting Expo Token

const getToken = async () => {
console.log("TOKEN CHECK");
const { status: existingStatus } =
await Notifications.getPermissionsAsync();
let finalStatus = existingStatus;
if (existingStatus !== "granted") {
const { status } = await Notifications.requestPermissionsAsync();
finalStatus = status;
}
if (finalStatus !== "granted") {
alert("Failed to get push token for push notification!");
return;
}
token = (await Notifications.getExpoPushTokenAsync()).data;
console.log(token);
};

App.js

{
"name": "myapp",
"displayName": "myapp",
"expo": {
"name": "myapp",
"slug": "myapp",
"version": "1.0.0",
"assetBundlePatterns": [
"**/*"
]
},
"android": {
"googleServicesFile": "./google-services.json",
"useNextNotificationsApi": true
}
}

Package.json

{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start"
},
"dependencies": {
"@dudigital/react-native-zoomable-view": "^1.0.16",
"@react-native-async-storage/async-storage": "^1.15.5",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "^6.0.0",
"@react-native-firebase/app": "^12.0.0",
"@react-native-firebase/firestore": "^12.0.0",
"@react-native-firebase/storage": "^12.0.0",
"@react-native-picker/picker": "^1.16.1",
"@react-navigation/material-bottom-tabs": "^5.3.15",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"expo": "~41.0.1",
"expo-av": "~9.1.2",
"expo-image-manipulator": "~9.1.0",
"expo-image-picker": "~10.1.4",
"expo-notifications": "~0.11.6",
"expo-splash-screen": "~0.10.2",
"expo-status-bar": "~1.0.4",
"expo-updates": "~0.5.4",
"expo-web-browser": "~9.1.0",
"firebase": "^8.6.5",
"moment": "^2.29.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.4",
"react-native-calendars": "^1.1263.0",
"react-native-custom-qr-codes-expo": "^2.2.0",
"react-native-datepicker": "^1.7.2",
"react-native-gesture-handler": "~1.10.2",
"react-native-linear-gradient": "^2.5.6",
"react-native-orientation-locker": "^1.3.1",
"react-native-paper": "^4.9.1",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-reanimated": "~2.1.0",
"react-native-render-html": "^5.1.1",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "~3.0.0",
"react-native-shimmer-placeholder": "^2.0.7",
"react-native-svg": "12.1.0",
"react-native-unimodules": "~0.13.3",
"react-native-vector-icons": "^8.1.0",
"react-native-web": "~0.13.12",
"react-native-webview": "^11.6.2"
},
"devDependencies": {
"@babel/core": "^7.9.0"
},
"private": true
}

截图: someImages

最佳答案

你必须做两件事:

  1. 在裸工作流中,Notifications.getExpoPushTokenAsync() 方法需要提供 experienceId 属性。

const expoPushToken = await Notifications.getExpoPushTokenAsync({ experienceId });

console.log({ expoPushToken });

return expoPushToken.data;

  1. 您必须修改您的/android/app/build.gradle 以添加'com.google.firebase:firebase-iid:17.0.2'

    依赖关系{实现 'com.google.firebase:firebase-iid:17.0.2'...

关于expo - 由于 : Lcom/google/firebase/iid/FirebaseInstanceId; 的解析失败,无法在 Expo Notification 中获取 expoToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67867045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com