How to Retrieve iOS Bundle ID and Android Package Name for Registering React Native Expo App with Firebase JS SDK?

huangapple go评论45阅读模式
英文:

How to Retrieve iOS Bundle ID and Android Package Name for Registering React Native Expo App with Firebase JS SDK?

问题

我一直在努力寻找解决方法,以获取iOS Bundle ID和Android包名,以便在Firebase上注册我的React Native Expo应用程序,使用Firebase JavaScript SDK。我已经进行了广泛的搜索,但还没有找到明确的答案。

我需要切换到React Native Firebase而不是使用Firebase JavaScript SDK吗?

我将非常感激对此事的任何帮助或指导。提前感谢。

这是我的app.json

{
  "expo": {
    "name": "testingfirebase",
    "slug": "testingfirebase",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "supportsTablet": true
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}
英文:

I've been struggling to find a solution for obtaining the iOS Bundle ID and Android Package Name to register my React Native Expo app on Firebase using the Firebase JavaScript SDK. I've searched extensively, but haven't been able to find a clear answer.

Do I need to switch to React Native Firebase instead of using the Firebase JavaScript SDK?

I would greatly appreciate any assistance or guidance on this matter. Thank you in advance.

This is my app.json:

{
  "expo": {
    "name": "testingfirebase",
    "slug": "testingfirebase",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "googleServicesFile": "./GoogleService-Info.plist",
      "supportsTablet": true
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      "@react-native-firebase/app",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

答案1

得分: 1

有两种与 Expo 一起使用 Firebase SDK 交互的方式。

1. Firebase JavaScript SDK(专为 Web 设计)

Firebase将您的应用视为Web应用程序,您无需配置iOS或Android包ID。

Firebase JS SDK的功能有限 - 不支持云消息传递/通知和Crashlytic。

文档 - https://docs.expo.dev/guides/using-firebase/#using-firebase-js-sdk

2. 使用 React Native Firebase

此包使用适用于Android和iOS的相应本机SDK。这需要为每个平台提供包ID。

文档 - https://docs.expo.dev/guides/using-firebase/#install-and-initialize-react-native-firebase

英文:

There are 2 ways to interact with Firebase SDK with Expo.

1. Firebase JavaScript SDK (Designed for the web)

Firebase treats your app as a web app and you don't need to configure either ios or Android package ID.

Firebase JS SDK has limited features - Cloud Messaging/Notification, and Crashlytic are not supported.

Docs - https://docs.expo.dev/guides/using-firebase/#using-firebase-js-sdk

2. Use React Native Firebase

This package uses the corresponding Native SDKs for both Android and ios. This requires a package ID for each platform.

Docs - https://docs.expo.dev/guides/using-firebase/#install-and-initialize-react-native-firebase

答案2

得分: -1

要使用Firebase JavaScript SDK在Firebase上注册您的React Native Expo应用程序,您需要获取iOS Bundle ID和Android包名称。下面是如何找到它们的方法:

iOS Bundle ID:Expo会为您创建iOS Bundle ID。您可以在Expo项目的app.json文件中找到它。查找“ios”部分和“bundleIdentifier”键。与此键关联的值就是您的iOS Bundle ID。

"ios": {
  "bundleIdentifier": "com.yourcompany.yourapp"
}

Android包名称:同样,Android包名称可以在您的Expo项目的app.json文件中找到。查找“android”部分和“package”键。与此键关联的值就是您的Android包名称。

"android": {
  "package": "com.yourcompany.yourapp"
}

有了这些值,您可以使用Firebase JavaScript SDK在Firebase上注册您的应用程序。除非您明确需要该库提供的功能,否则您不必切换到React Native Firebase。

请注意,Firebase JavaScript SDK在涉及某些更适合原生开发的Firebase功能或服务方面可能存在限制。如果您发现您需要额外的功能或在JavaScript SDK方面存在限制,您可以考虑使用React Native Firebase,它提供了专为React Native应用程序设计的更全面的Firebase功能集。

英文:

To register your React Native Expo app on Firebase using the Firebase JavaScript SDK, you need to obtain the iOS Bundle ID and Android Package Name. Here's how you can find them:

iOS Bundle ID: Expo manages the creation of the iOS Bundle ID for you. You can find it in your Expo project's app.json file. Look for the "ios" section and the "bundleIdentifier" key. The value associated with this key is your iOS Bundle ID.

"ios": {
  "bundleIdentifier": "com.yourcompany.yourapp"
}

Android Package Name: Similarly, the Android Package Name can be found in the app.json file of your Expo project. Look for the "android" section and the "package" key. The value associated with this key is your Android Package Name.

"android": {
  "package": "com.yourcompany.yourapp"
}

With these values, you can register your app on Firebase using the Firebase JavaScript SDK. You don't necessarily need to switch to React Native Firebase unless you specifically require features provided by that library.

Please note that the Firebase JavaScript SDK may have limitations when it comes to certain Firebase features or services that are more tailored to native development. If you find that you need additional functionality or face limitations with the JavaScript SDK, you can consider using React Native Firebase, which provides a more comprehensive set of Firebase functionalities specifically designed for React Native apps.

huangapple
  • 本文由 发表于 2023年6月22日 08:20:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76527905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定