From f4c1596714dfdbad3e50d8733bb6a4eedbd563ad Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 4 Jun 2019 14:20:46 +0100 Subject: [PATCH] [docs] ml natural language docs & firebase.json docs --- docs/app/firebase-json.md | 98 +++++++++++++++++++ docs/ml-kit/android.md | 11 --- docs/ml-kit/quick-start.md | 32 ------ docs/ml-natural-language/android.md | 48 +++++++++ docs/{ml-kit => ml-natural-language}/index.md | 15 ++- docs/{ml-kit => ml-natural-language}/ios.md | 4 +- docs/ml-natural-language/quick-start.md | 53 ++++++++++ 7 files changed, 212 insertions(+), 49 deletions(-) create mode 100644 docs/app/firebase-json.md delete mode 100644 docs/ml-kit/android.md delete mode 100644 docs/ml-kit/quick-start.md create mode 100644 docs/ml-natural-language/android.md rename docs/{ml-kit => ml-natural-language}/index.md (67%) rename docs/{ml-kit => ml-natural-language}/ios.md (92%) create mode 100644 docs/ml-natural-language/quick-start.md diff --git a/docs/app/firebase-json.md b/docs/app/firebase-json.md new file mode 100644 index 00000000..655f53df --- /dev/null +++ b/docs/app/firebase-json.md @@ -0,0 +1,98 @@ +--- +title: Configure via firebase.json +description: Configure your Firebase services via a `firebase.json` file. +--- + +# React Native Firebase JSON Configuration + +As part of the many steps we've taken to simplify using Firebase with React Native; React Native Firebase now allows you to configure various options across all its supported Firebase services via a single `firebase.json` file in your project root. + +These options are here to replace steps where you'd normally have to make native code changes to your project. + +**Supported Platforms:** Android, iOS (via CocoaPods only) + +## Structure + +All options for React Native Firebase must be placed inside a wrapping `react-native` object. + +**Supported Values**: `boolean`, `string`, `number` + +> Nested items inside `"react-native"` are not supported. + +### Example + +```json +{ + "react-native": { + "crashlytics_ndk_enabled": true, + "crashlytics_debug_enabled": true, + "crashlytics_auto_collection_enabled": false, + + "ml_natural_language_language_id_model" : true, + "ml_natural_language_smart_reply_model" : false, + + "ml_vision_face_model" : true, + "ml_vision_image_label_model" : false, + "ml_vision_object_detection_model" : true, + + "messaging_auto_init_enabled": false + } +} +``` + +## Non Firebase Usage + +You may find it useful to use it for non-Firebase things in your project, e.g: + + - toggling a feature + - injecting values into your Android manifest + - switching Android source sets + - controlling optional dependencies + - controlling native dependency versions + - customising build time logic + - customising runtime logic + - switching which podspec to use based + +All config items in a `firebase.json` file can be read at every stage of your app's build/run cycle: + + - Android + - Inside Gradle build + - Inside native code (e.g. Java) + - iOS + - Inside Script Phases + - Inside Pod install (e.g. can be read inside pod specs) + - Inside native code (e.g. Objective-C) + - JS + - Inside your app bundle + - RN CLI - Project Config (`react-native.config.js`) + - RN CLI - Dependency Config (`react-native.config.js`) + + To help you with this we've documented the internal APIs that are accessible at every location: + + #### Android - Runtime (Java) + + TODO + + #### Android - Build time (Groovy) + + TODO + + #### iOS - CocoaPods (Ruby) + + TODO + + #### iOS - Script Phases (Bash) + + TODO + + #### iOS - Runtime (Objective-C) + + TODO + + #### RN CLI - Project Config (`react-native.config.js`) + + TODO + + #### RN CLI - Dependency Config (`react-native.config.js`) + + TODO diff --git a/docs/ml-kit/android.md b/docs/ml-kit/android.md deleted file mode 100644 index 5c71e671..00000000 --- a/docs/ml-kit/android.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Android Setup -description: Manually integrate ML Kit into your Android application. ---- - -# Android Setup - -> The following steps are only required if your environment does not have access to React Native -auto-linking. - -## TODO diff --git a/docs/ml-kit/quick-start.md b/docs/ml-kit/quick-start.md deleted file mode 100644 index d7937cde..00000000 --- a/docs/ml-kit/quick-start.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: Quick Start -description: Get to grips with the basics of ML Kit in React Native Firebase ---- - -# ML Kit Quick Start - -## Installation - -Install this module with Yarn: - -```bash -yarn add @react-native-firebase/mlkit@alpha -``` - -> Integrating manually and not via React Native auto-linking? Check the setup instructions for Android & iOS. - -## Module usage - -Import the ML Kit package into your project: - -```js -import mlkit from '@react-native-firebase/mlkit'; -``` - -The package also provides access to the firebase instance: - -```js -import { firebase } from '@react-native-firebase/mlkit'; -``` - -### TODO diff --git a/docs/ml-natural-language/android.md b/docs/ml-natural-language/android.md new file mode 100644 index 00000000..32f2a140 --- /dev/null +++ b/docs/ml-natural-language/android.md @@ -0,0 +1,48 @@ +--- +title: Android Setup +description: Manually integrate ML Kit Natural Language into your Android application. +--- + +# Android Setup + +## Manual Android Integration + +> The following steps are only required if your environment does not have access to React Native +> auto-linking. + +#### Add ML Kit Natural Language to Gradle Settings + +**`android/settings.gradle`**: + +```groovy +include ':@react-native-firebase_ml-natural-language' +project(':@react-native-firebase_ml-natural-language').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/ml-natural-language/android') +``` + +#### Add ML Kit Natural Language to App Gradle Dependencies + +**`android/app/build.gradle`**: + +```groovy{4} +// .. +dependencies { + // .. + implementation project(path: ":@react-native-firebase_ml-natural-language") +} +``` + +#### Add ML Kit Natural Language to Main Android Application: + +**`android/app/src/main/java/**/MainApplication.java`\*\*: + +```java{2,8} +// .. +import io.invertase.firebase.ml.naturallanguage.ReactNativeFirebaseMLNaturalLanguagePackage; + + // .. + protected List getPackages() { + return Arrays.asList( + new MainReactPackage(), + new ReactNativeFirebaseMLNaturalLanguagePackage(), + // .. +``` diff --git a/docs/ml-kit/index.md b/docs/ml-natural-language/index.md similarity index 67% rename from docs/ml-kit/index.md rename to docs/ml-natural-language/index.md index 8f5547bf..fdf6e7f2 100644 --- a/docs/ml-kit/index.md +++ b/docs/ml-natural-language/index.md @@ -1,14 +1,21 @@ --- -title: ML Kit -description: ML Kit lets you bring powerful machine learning features to your React Native app. +title: ML Kit Natural Language +description: ML Kit Natural Language APIs lets you bring powerful Natural Language machine learning features into your React Native app. --- -# ML Kit +# ML Kit - Natural Language Firebase ML Kit brings the power of machine learning to your React Native application, supporting both Android & iOS. +ML Kit Natural Language for React Native currently supports the following APIs: + +- [Language Identification](https://firebase.google.com/docs/ml-kit/identify-languages) +- [Smart Reply](https://firebase.google.com/docs/ml-kit/generate-smart-replies) + +Support for Translate APIs coming in a later release. + ## Getting Started @@ -41,7 +48,7 @@ Firebase ML Kit brings the power of machine learning to your React Native applic ## Learn more -Our documentation is a great place to start, however if you're looking for more help or want to help others, +Our documentation is a great place to start, however if you're looking for more help or want to help others, check out the resources below: - [Stack Overflow](https://stackoverflow.com/questions/tagged/react-native-firebase-mlkit) diff --git a/docs/ml-kit/ios.md b/docs/ml-natural-language/ios.md similarity index 92% rename from docs/ml-kit/ios.md rename to docs/ml-natural-language/ios.md index a08fc802..f1be754b 100644 --- a/docs/ml-kit/ios.md +++ b/docs/ml-natural-language/ios.md @@ -1,11 +1,11 @@ --- title: iOS Setup -description: Manually integrate ML Kit into your iOS application. +description: Manually integrate ML Kit into your iOS application. --- # iOS Setup > The following steps are only required if your environment does not have access to React Native -auto-linking. +> auto-linking. ## TODO diff --git a/docs/ml-natural-language/quick-start.md b/docs/ml-natural-language/quick-start.md new file mode 100644 index 00000000..1301bd2d --- /dev/null +++ b/docs/ml-natural-language/quick-start.md @@ -0,0 +1,53 @@ +--- +title: Quick Start +description: Get to grips with the basics of ML Kit in React Native Firebase +--- + +# ML Kit Quick Start + +## Installation + +Install this module with Yarn: + +```bash +yarn add @react-native-firebase/ml-natural-language@alpha +``` + +> Integrating manually and not via React Native auto-linking? Check the setup instructions for Android & iOS. + +## Module usage + +Import the ML Kit package into your project: + +```js +import mlNaturalLanguage from '@react-native-firebase/ml-natural-language'; +``` + +The package also provides access to the firebase instance: + +```js +import { firebase } from '@react-native-firebase/ml-natural-language'; +``` + +### Configuring Models + +To be able to use the APIs you'll need to enable the models for the APIs you wish to use. + +React Native Firebase allows you to configure these in via a `firebase.json` file in your project root. + +Add any of the keys indicated below to your JSON file and set them to `true` to enable them. All models and APIs are disabled (`false`) by default. + +```json5 +{ + "react-native": { + // Language Identification + "ml_natural_language_language_id_model": false, + // Smart Replies + "ml_natural_language_smart_reply_model": false + } +} +``` + +> If you are manually linking on iOS (e.g. not using CocoaPods) then it's up to you to manage these models and dependencies yourself - `firebase.json` support is only for Android and iOS (via Pods). + +To learn more, view the App documentation.