{"id":4434,"url":"https://github.com/corymsmith/react-native-fabric","last_synced_at":"2025-04-13T23:54:48.219Z","repository":{"id":3551448,"uuid":"50048841","full_name":"corymsmith/react-native-fabric","owner":"corymsmith","description":"A React Native library for Fabric, Crashlytics and Answers","archived":false,"fork":false,"pushed_at":"2022-12-07T14:16:09.000Z","size":39829,"stargazers_count":1307,"open_issues_count":66,"forks_count":236,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-10-29T15:24:07.772Z","etag":null,"topics":["answers","crashlytics","fabric","react-native"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corymsmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-20T17:55:40.000Z","updated_at":"2024-10-23T12:04:01.000Z","dependencies_parsed_at":"2023-01-13T13:00:18.686Z","dependency_job_id":null,"html_url":"https://github.com/corymsmith/react-native-fabric","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corymsmith%2Freact-native-fabric","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corymsmith%2Freact-native-fabric/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corymsmith%2Freact-native-fabric/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corymsmith%2Freact-native-fabric/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corymsmith","download_url":"https://codeload.github.com/corymsmith/react-native-fabric/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799914,"owners_count":21163403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["answers","crashlytics","fabric","react-native"],"created_at":"2024-01-05T20:17:11.822Z","updated_at":"2025-04-13T23:54:48.186Z","avatar_url":"https://github.com/corymsmith.png","language":"Objective-C","funding_links":[],"categories":["Components","Objective-C","组件","Libraries","Objective-C  Stars 1000以内排名整理"],"sub_categories":["Analytics","工具包","工具"],"readme":"# react-native-fabric\nA React Native library for Fabric, Crashlytics and Answers\n\n[![NPM](https://nodei.co/npm/react-native-fabric.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/react-native-fabric/)\n\n\n## Versioning\n- For React Native \u003e 0.40 use version 0.5.1\n- For React Native \u003c 0.40 use version 0.3.2\n\nFor Twitter Kit support, see [react-native-fabric-twitterkit](https://github.com/tkporter/react-native-fabric-twitterkit)\n\n## Installation\n\n### 1. Add Fabric / Crashlytics to your project\n\n- First, set up Fabric / Crashlytics in your app as instructed on [Fabric.io](https://fabric.io).  This includes downloading the fabric app and walking through the setup steps (downloading the SDK, adding it to your project and making some changes to your project).\n\n### 2. Add react-native-fabric\n\n#### Automatically\n\n`react-native install react-native-fabric`, or with [rnpm](https://github.com/rnpm/rnpm): `rnpm install react-native-fabric`\n\nReact Native / rnpm will automatically link all the necessary libraries for both iOS and Android.\n\nIf the installation goes off without a hitch, you can now skip to the **[Crashlytics Usage section](#crashlytics-usage)** or the **[Answers Usage section](#answers-usage)**.\n\n#### Manually\n\n`npm install react-native-fabric --save`\n\n- Alternatively for Android, if you **don't** use Android studio you can skip the first step and instead follow the steps described in [`Android`](#android) **as well as** the steps in [`Android without Android Studio`](#no_android_studio).\n\n##### Manually iOS With CocoaPods support\n\n- add the following line to Podfile\n\n`pod 'ReactNativeFabric', :path =\u003e '../node_modules/react-native-fabric'`\n\n##### Manually iOS Without CocoaPods support\n\nDownload the [Crashlytics\nSDK](https://fabric.io/kits/ios/crashlytics/manual-install) and place the two\nframeworks in a directory called `Crashlytics` in the `ios` directory. You may\nwant to add this directory to your `.gitignore` as they take up a decent amount\nof space and will slow down Git.\n\nYou will also need to modify the Run Script Phase that you likely added to Build\nPhases so that it points to the correct location for the Fabric framework. If\nyou placed the framework directly under `ios/Crashlytics` as specified above,t\nthe contents of the script will then be:\n\n```\n\"${SRCROOT}/Crashlytics/Fabric.framework/run\" API_KEY API_SECRET\n```\n\nThen do the following:\n\n- Open your project in Xcode\n- Run ```open node_modules/react-native-fabric/ios```\n- Drag `SMXCrashlytics.xcodeproj` into your `Libraries` group\n- Select your main project in the navigator to bring up settings\n- Under `Build Phases` expand the `Link Binary With Libraries` header\n- Scroll down and click the `+` to add a library\n- Find and add `libSMXCrashlytics.a` under the `Workspace` group\n- ⌘+B\n\n\u003ca name=\"android\"\u003e\u003c/a\u003e\n##### Android\n\n*Note: Android support requires React Native 0.16 or later \n\n* Edit `android/settings.gradle` to look like this (without the +):\n\n  ```diff\n  rootProject.name = 'MyApp'\n\n  include ':app'\n\n  + include ':react-native-fabric'\n  + project(':react-native-fabric').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fabric/android')\n  ```\n\n* Edit `android/app/build.gradle` (note: **app** folder) to look like this: \n\n  ```diff\n  apply plugin: 'com.android.application'\n\n  android {\n    ...\n  }\n\n  dependencies {    \n    compile 'com.android.support:appcompat-v7:23.0.0'\n    compile 'com.facebook.react:react-native:0.19.+'\n  + compile project(':react-native-fabric')\n  }\n  ```\n\n* RN \u003c 0.29 - Edit your `MainActivity.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):\n\n  ```diff\n  package com.myapp;\n\n  + import com.smixx.fabric.FabricPackage;\n\n  ....\n  public class MainActivity extends ReactActivity {\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n        return Arrays.\u003cReactPackage\u003easList(\n  +         new FabricPackage(),\n            new MainReactPackage()\n        );\n    }\n  }\n  ```\n\n* RN 0.29+ - Edit your `MainApplication.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):\n\n  ```diff\n  package com.myapp;\n\n  + import com.smixx.fabric.FabricPackage;\n\n  ....\n  public class MainApplication extends Application implements ReactApplication {\n    @Override\n    protected List\u003cReactPackage\u003e getPackages() {\n        return Arrays.\u003cReactPackage\u003easList(\n  +         new FabricPackage(),\n            new MainReactPackage()\n        );\n    }\n  }\n  ```  \n\n\u003ca name=\"no_android_studio\"\u003e\u003c/a\u003e\n##### Android without Android Studio\n\nMake sure you also follow the steps described in [`Android`](#android).\n\n* Edit your `build.gradle` (note: **app** folder) to look like this:\n\n  ```diff\n  apply plugin: \"com.android.application\"\n\n  + buildscript {\n  +   repositories {\n  +     maven { url 'https://maven.fabric.io/public' }\n  +   }\n  +   dependencies {\n  +     // The Fabric Gradle plugin uses an open ended version to react\n  +     // quickly to Android tooling updates\n  +     classpath 'io.fabric.tools:gradle:1.+'\n  +   }\n  + }\n  + apply plugin: 'io.fabric'\n  + repositories {\n  +   maven { url 'https://maven.fabric.io/public' }\n  + }\n\n  [...]\n\n  dependencies {\n      [...]\n  +     compile('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {\n  +         transitive = true;\n  +     }\n  }\n  ```\n\n* RN \u003c 0.29 - Edit your `MainActivity.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):\n\n  ```diff\n  + import android.os.Bundle;\n  + import com.crashlytics.android.Crashlytics;\n  + import io.fabric.sdk.android.Fabric;\n\n  public class MainActivity extends ReactActivity {\n\n  +   @Override\n  +   protected void onCreate(Bundle savedInstanceState) {\n  +       super.onCreate(savedInstanceState);\n  +       Fabric.with(this, new Crashlytics());\n  +   }\n\n    [...]\n\n  }\n  ```\n\n* RN 0.29+ - Edit your `MainApplication.java` (deep in `android/app/src/main/java/...`) to look like this (note **two** places to edit):\n\n  ```diff\n  + import com.crashlytics.android.Crashlytics;\n  + import io.fabric.sdk.android.Fabric;\n  \n  public class MainApplication extends Application implements ReactApplication {\n  \n  +   @Override\n  +   public void onCreate() {\n  +       super.onCreate();\n  +       Fabric.with(this, new Crashlytics());\n  +   }\n  \n    [...]\n  \n  }\n  ``` \n\n* Note: the `onCreate` access privilege goes from `protected` to `public` from RN 0.28+\n\n* Edit your `AndroidManifest.xml` (in `android/app/src/main/`) to look like this. Make sure to enter your fabric API key after `android:value=`, you can find your key on your fabric organisation page.\n\n  ```diff\n  \u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      [...]\n      \u003capplication\n        [...]\n  +       \u003cmeta-data\n  +         android:name=\"io.fabric.ApiKey\"\n  +         android:value=[YOUR API KEY]\n  +       /\u003e\n      \u003c/application\u003e\n  +   \u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n  \u003c/manifest\u003e\n  ```\n\n## Crashlytics Usage\n\n**Note: logging will not be registered on Android to the Fabric dashboard until the app is bundled for release.**\n\nTo see all available methods take a look at [Crashlytics.js](https://github.com/corymsmith/react-native-fabric/blob/master/src/Crashlytics.js)\n\n```js\nvar Fabric = require('react-native-fabric');\n\nvar { Crashlytics } = Fabric;\n\nCrashlytics.setUserName('megaman');\n\nCrashlytics.setUserEmail('user@email.com');\n\nCrashlytics.setUserIdentifier('1234');\n\nCrashlytics.setBool('has_posted', true);\n\nCrashlytics.setString('organization', 'Acme. Corp');\n\n// Forces a native crash for testing\nCrashlytics.crash();\n\n// Due to differences in primitive types between iOS and Android I've exposed a setNumber function vs. setInt, setFloat, setDouble, setLong, etc                                        \nCrashlytics.setNumber('post_count', 5);\n\n// Record a non-fatal JS error only on Android\nCrashlytics.logException('');\n\n// Record a non-fatal JS error only on iOS\nCrashlytics.recordError('something went wrong!');\n\n```\n\n## Answers Usage\nTo see all available function take a look at [Answers.js](https://github.com/corymsmith/react-native-fabric/blob/master/src/Answers.js)\n\n```js\nvar Fabric = require('react-native-fabric');\n\nvar { Answers } = Fabric;\n\n// All log functions take an optional object of custom attributes as the last parameter\nAnswers.logCustom('Performed a custom event', { bigData: true });\n\nAnswers.logContentView('To-Do Edit', 'To-Do', 'to-do-42', { userId: 93 });\n\nAnswers.logAddToCart(24.50, 'USD', 'Air Jordans', 'shoes', '987654', {color: 'red'});\n\nAnswers.logInvite('Facebook');\n\nAnswers.logLogin('Twitter', true);\n\nAnswers.logSearch('React Native');\n\nAnswers.logShare('Twitter', 'Big news article', 'post', '1234');\n\nAnswers.logSignUp('Twitter', true);\n\nAnswers.logPurchase(24.99,'USD',true, 'Air Jordans', 'shoes', '987654');\n\n\n``` \n\n\n## License\nMIT © Cory Smith 2016\n\n\n[rnpm]: https://github.com/rnpm/rnpm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymsmith%2Freact-native-fabric","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorymsmith%2Freact-native-fabric","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymsmith%2Freact-native-fabric/lists"}