这是React Native项目。在Android Studio模拟器中成功构建后出现错误:
java.lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / firebase / FirebaseApp
我的文件:
package.json:
...
"react-native": "^0.55.3",
"react-native-camera": "1.1.2",
"react-native-check-box": "^2.1.0",
"react-native-extended-stylesheet": "^0.8.1",
"react-native-firebase": "^4.2.0",
"react-native-geocoder": "^0.5.0",
"react-native-git-upgrade": "^0.2.7",
"react-native-htmlview": "^0.12.1",
"react-native-image-picker": "^0.26.10",
"react-native-linear-gradient": "^2.4.0",
"react-native-local-storage": "^1.5.2",
"react-native-maps": "^0.21.0",
"react-native-modal": "^5.4.0",
"react-native-modal-dropdown": "^0.6.1",
"react-native-read-more-text": "^1.0.0",
"react-native-router-flux": "^4.0.0-beta.27",
"react-native-svg-image": "^2.0.1",
"react-native-text-input-mask": "^0.7.0",
...
Run Code Online (Sandbox Code Playgroud)
android / app / build.gradle:
...
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.something.anything"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
} …Run Code Online (Sandbox Code Playgroud) 我当前在 React Native 上的 android 目标 sdk 是 28,但 Play Store 显示将其更新为 29。所以我在 android/build.gradle 中进行了以下更改
buildscript {
ext {
googlePlayServicesVersion = "16.0.0"
firebaseVersion = "17.3.4"
buildToolsVersion = "28.0.3" //changed to 29.0.3
minSdkVersion = 16
compileSdkVersion = 28 //changed to 29
targetSdkVersion = 28 // changed to 29
supportLibVersion = "28.0.0"
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在当我运行 npx react-native run-android 时出现以下错误。
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.android.support:support-v4:29.0.0.
Required by:
project :app
project :app > project :react-native-firebase
> …Run Code Online (Sandbox Code Playgroud) 当我尝试构建生产时,会出现此错误。我正在使用 React Native Firebase。这个错误发生在安卓上。
这是错误
* What went wrong:
Execution failed for task ':react-native-firebase_app:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-firebase_app:releaseCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=release, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find react-native-0.71.0-rc.0-release.aar (com.facebook.react:react-native:0.71.0-rc.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/react/react-native/0.71.0-rc.0/react-native-0.71.0-rc.0-release.aar
Run Code Online (Sandbox Code Playgroud)
这是我的包裹
[tag: "@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-firebase/analytics": "^16.4.3",
"@react-native-firebase/app": "^16.4.3",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1",
"@rneui/base": "^4.0.0-rc.7",
"@rneui/themed": "^4.0.0-rc.7",
"meilisearch": "^0.29.1",
"native-base": "^3.4.21",
"picomatch": "^2.3.1",
"react": "18.1.0",
"react-native": "0.70.3",
"react-native-firebase": …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用react-native-firebase框架将Firebase集成到我的expo应用firebase程序中,当涉及到本机应用时,它比常规软件包有几个优势.
但是,我遇到了困难,因为说明我必须添加GoogleService-Info.plist到ios/[YOUR APP NAME]/GoogleService-Info.plist,并且expo应用程序没有我理解的ios文件夹.
我差点搞砸了还是有解决方案?
我正在尝试使用Firebase(Cloud Firestore)作为本机应用程序,以存储我的JSON对象。
我见过人们在他们的应用程序中使用Firebase (npm install firebase),而其他人则使用react-native-firebase。
大多数博客都说Firebase本身是用于Web的,因此它们的本机响应支持是“无/少”。而其他一些博客和firebase官方博客则说Firebase支持本地本机。
我不确定为我的本机项目选择哪个库,它们之间有什么区别。
firebase react-native google-cloud-firestore react-native-firebase
我已经react-native-fcm在Android和iPhone中用于远程通知。
在Android前景中,我无法在通知栏中获得远程通知。
在后台模式下,我能够成功获取通知,但在前台却不能。
Android Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nusape">
<application>
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="my_default_channel"/>
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<activity android:launchMode="singleTop" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
App.js …
android react-native remote-notifications firebase-cloud-messaging react-native-firebase
每当我尝试使用 react-native-firebase sdk 使用电话号码登录时,我都会通过短信收到 OTP 代码,当我提交收到的代码时,会出现错误消息:“短信代码已过期。请重新发送验证码再试一次。” 在这里要注意的是,即使出现错误,相应电话号码的条目也会写入 firebase 的“用户”部分。
我正在使用以下内容:
NodeJS: v8.11.1,
NPM: v5.6.0,
react-native: "^0.59.9",
react-native-firebase: "^5.5.3"
Run Code Online (Sandbox Code Playgroud)
我已经尝试过的一些链接是:
1. https://github.com/invertase/react-native-firebase-
docs/blob/master/docs/auth/phone-auth.md
2. /sf/ask/3256590851/
authentication-error-the-sms-code-has-expired
3. https://www.bountysource.com/issues/45308170-firebase-phone-
number-auth-integration
4. https://medium.com/@chrisbianca/getting-started-with-firebase-
authentication-on-react-native-a1ed3d2d6d91
5. https://invertase.io/oss/react-native-firebase/v6/auth/phone-
auth
Run Code Online (Sandbox Code Playgroud)
在 MobileRegistration.js 中:
navigateToOtpScreen() {
console.log("Phone number: ", "+91" + this.state.phoneNumber)
firebase.auth().signInWithPhoneNumber("+91" +
this.state.phoneNumber)
.then(confirmResult => {
this.setState({ confirmResult, message: 'Code has been sent!'})
this.props.navigation.navigate('EnterOtp', { 'confirmResult':
confirmResult})
})
.catch(error => {
alert(error.message);
this.setState({ message: `Sign In With Phone Number Error:
${error.message}` })
});
Run Code Online (Sandbox Code Playgroud)
};
在 …
react-native firebase-authentication react-native-android react-native-firebase
我正在使用 firebase 动态链接。这在安装在 ios 或 android 上的应用程序中运行良好。好像应用程序未安装在 android 上一样,它会将我重定向到 Play 商店。但是在 ios 中,如果安装了应用程序,它就可以正常工作。但是当我卸载 ios 应用程序时,它不会将我重定向到应用程序。它只是打开深层链接。如果未安装应用程序,我想打开应用程序商店。请检查我是否做错了什么/
const shareLink = new firebase.links.DynamicLink(
deepLink,
firebaseDynamicLinkPrefix
).android.setPackageName(identifierAndroid)
.ios.setBundleId(identifierIOS);
const linkk = await firebase
.links()
.createShortDynamicLink(shareLink, 'UNGUESSABLE')
.then(url => {
return url
})
.catch(e => console.log('ERROR', e));
Run Code Online (Sandbox Code Playgroud) firebase react-native firebase-dynamic-links react-native-firebase
我们正在使用React Native Firebase 版本 6消息传递来处理推送通知。从远程通知内容来看,我们无法在 ios 上增加/减少徽章计数。所以我们使用推送通知 ios来设置徽章计数。
当应用程序位于前台和后台时,它运行得很好。但是当应用程序关闭时,我们能够收到通知,但无法更新徽章计数。
messaging().onMessage(async remoteMessage => {
Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));
});
messaging().setBackgroundMessageHandler(async remoteMessage => {
PushNotificationIOS.getApplicationIconBadgeNumber(number => {
PushNotificationIOS.setApplicationIconBadgeNumber(number + 1);
});
asyncstorage.saveItem("remoteMessage", "only one killed message received");
});
Run Code Online (Sandbox Code Playgroud)
当应用程序处于后台状态时,这里setBackgroundMessageHandler正在工作。根据文档,即使应用程序关闭,此方法也应该调用。但事实并非如此。为了获得更多说明,当应用程序终止时,我在该方法中执行了异步存储操作。但它没有按预期工作。
我还添加了服务器端数据,这些数据是我从后端发送的通知,
{
"to":".................",
"notification":{
"title":"Working Good",
"body":"backgroudn noti",
"badge":"1",
"sound":"./app/assets/sound/alert.wav"
},
"priority":"high",
"badge":"1",
"content_available":true
}
Run Code Online (Sandbox Code Playgroud)
我想提一下这些键的一些要点,
通知对象内有一个徽章,每次关闭应用程序时都会将其设置为图标。但无法增加/减少徽章计数。它始终是 1。
添加“content_available”属性后,我能够更新徽章计数。这意味着仅添加 content_available 后,我在setBackgroundMessageHandler方法中获得了触发器,并使用推送通知 ios 属性更新了徽章计数。
现在,当应用程序关闭时,我在setBackgroundMessageHandler方法中没有收到任何触发器。
即使应用程序已关闭,我是否需要添加任何其他键才能在setBackgroundMessageHandler方法内获取触发器? …
push-notification badge react-native react-native-ios react-native-firebase
我试图在使用 react-native-firebase 的 react-native 应用程序中的一次调用中执行各种 firebase 操作。流程是这样的:
在图像存储阶段,该imgRef.putFile()函数错误地指出用户未被授权。但是我正在使用createUserWithEmailAndPassword()(在完成时对用户进行身份验证),然后使用返回的凭据来完成其余的工作、图像存储和 Firestore 创建。
firebase 存储规则设置为仅允许经过身份验证的用户。这是规则集:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
另外,我在身份验证方法中启用了匿名登录。
这是直到错误点的初始操作:
return (dispatch) => {
dispatch({ type: types.REGISTER_USER });
console.log('starting registration process...');
firebase
.firestore()
.collection('users')
.where('username', '==', username)
.get()
.then((querySnapshot) => {
console.log(querySnapshot);
if (querySnapshot.empty !== true) {
registrationFail(dispatch, 'Username already taken. Try again.');
console.log("Registrant's username already exists"); …Run Code Online (Sandbox Code Playgroud) javascript firebase react-native firebase-storage react-native-firebase