在模块ExpoPushTokenManager上执行导出的方法getDevicePushTokenAsync时发生异常



我升级了expo推送通知,每当我在Android上运行它时,我都会收到以下错误:

执行导出方法时发生异常模块ExpoPushTokenManager上的getDevicePushTokenAsync。请设置您的项目ID。需要有效的firebase项目ID才能与Firebase服务器API通信:它通过Goolge。

有人能告诉我应该把项目ID放在哪里吗?我在我的项目中的config.js文件中链接了它,但我觉得它也应该在我的app.json文件中,只是不能100%确定在哪里。

{
"expo": {
"name": "Galavant",
"slug": "Galavant",
"platforms": ["ios", "android", "web"],
"version": "2.0.8",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/logo_original.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"usesAppleSignIn": true,
"infoPlist": {
"NSCameraUsageDescription": "So you can add photos to your profile.",
"NSPhotoLibraryUsageDescription": "So you can add photos to your profile.",
"NSLocationWhenInUseUsageDescription": "So you can connect with people nearby."
},
"supportsTablet": true,
"bundleIdentifier": "com.test.test",
"buildNumber": "0.0.1",
"config": {
"googleSignIn": {
"reservedClientId": "com.googleusercontent.apps.12346789"
}
}
},
"android": {
"package": "com.test.test",
"useNextNotificationsApi": true,
"versionCode": 5,
"config": {
"googleMaps": {
"apiKey": "asdkjfkasjdf9837983rlkajshf"
},
"googleSignIn": {
"apiKey": "asdkjfkasjdf9837983rlkajshf", 
"certificateHash": "33345w4sdfasdkjfkasjdf9837983srlkajshf"
}
},
"permissions": [
"ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION",
"CAMERA",
"MANAGE_DOCUMENTS",
"READ_CONTACTS",
"READ_CALENDAR",
"WRITE_CALENDAR",
"READ_EXTERNAL_STORAGE",
"READ_PHONE_STATE",
"RECORD_AUDIO",
"USE_FINGERPRINT",
"VIBRATE",
"WAKE_LOCK",
"WRITE_EXTERNAL_STORAGE",
"com.anddoes.launcher.permission.UPDATE_COUNT",
"com.android.launcher.permission.INSTALL_SHORTCUT",
"com.google.android.c2dm.permission.RECEIVE",
"com.google.android.gms.permission.ACTIVITY_RECOGNITION",
"com.google.android.providers.gsf.permission.READ_GSERVICES",
"com.htc.launcher.permission.READ_SETTINGS",
"com.htc.launcher.permission.UPDATE_SHORTCUT",
"com.majeur.launcher.permission.UPDATE_BADGE",
"com.sec.android.provider.badge.permission.READ",
"com.sec.android.provider.badge.permission.WRITE",
"com.sonyericsson.home.permission.BROADCAST_BADGE"
]
},
"notification": {
"icon": "./assets/PushNotification.png"
}
}
}

我最终做了一些事情。首先,我创建并添加到google-services.json文件中。我在CCD_ 4部分中添加了项目ID;android";带有useNextNotificationsApi的部分

"android": {
"package": "com.test.test",
"googleServicesFile": "./google-services.json",
"useNextNotificationsApi": true,
"versionCode": 10,
"config": {
"googleMaps": {
"apiKey": "123456789"
},
"googleSignIn": {
"apiKey": "123456789",
"certificateHash": "123456789asdfasdf"
}
},
"permissions": [
"ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION",
"CAMERA",
"USE_FINGERPRINT",
"VIBRATE"
]
},
"web": {
"config": {
"firebase": {
"projectId": "testprojectID",
"apiKey": "123456789",
"measurementId": "measurementid123"
}
}
},

我试图切换到托管流,试图处理后台通知(在Expo Go中不起作用(,但得到了完全相同的错误(在提到projectId时获取Expo推送令牌时无法启动(。

我终于把我的工作做好了。如果它能帮助别人,我会在这里绊倒。。。

首先,我确认我有这两把钥匙:

"googleServicesFile": "./google-services.json",
"useNextNotificationsApi": true,

其次,我想我没有把所有的https://docs.expo.dev/push-notifications/using-fcm/完全正确。我有整个";客户端设置";正在工作,但后来忘记了做";上传服务器凭据";。

第三,可能也是最令人困惑的一点,我也是出版和更新的新手。我在我的应用程序上创建了一个调试页面,显示了它在Play Store中运行的版本(至少我认为它是这样(。但它只会在我将Play应用程序发布到内部测试后打开,然后关闭并重新打开时更新…在了解了更多关于OTA更新的信息后,我意识到这就是实际发生的事情,尽管我的Constants.manifest.android.version代码和应用程序版本似乎要更新,但我实际上并没有得到新的安卓密钥集的最新版本(因为它们以某种方式通过OTA交付(。

因此,修复我的最后一件事是通过Play手动卸载我的内部测试应用程序,然后从头开始重新安装!

解决我问题的是添加/android/app/build.grandle在依赖这个

implementation 'com.google.firebase:firebase-iid'

但在我的情况下,我以前遇到过其他问题,例如我忘记上传服务器凭据。文档没有明确说明这一点。在这个页面上,步骤更加清晰

上传服务器凭据

你也可以检查谷歌服务文件的路径是否是o

相关内容

  • 没有找到相关文章

最新更新