Giter Site home page Giter Site logo

just1and0 / react-native-unimodules Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unimodules/react-native-unimodules

1.0 2.0 0.0 42 KB

Core Unimodule infrastructure and a collection of Unimodules and interfaces that are commonly depended on by other Unimodules

License: MIT License

Ruby 39.08% Groovy 49.80% JavaScript 11.12%

react-native-unimodules's Introduction

react-native-unimodules

This library contains the core Unimodule infrastructure and a collection of Unimodules and interfaces that are commonly depended on by other Unimodules. You will need to install this before using libraries from Foundation, like expo-camera, expo-media-library, and others.

Installation

The easiest way to do this is to initialize a "bare" project with expo-cli using expo init --template bare-minimum.

If you have an existing app, you can follow these steps instead. This project requires that you use Cocoapods on iOS, to set it up see this gist, or relevant parts of the this guide.

Install the package

npm install react-native-unimodules

Configure iOS

  • Go back to the ios directory and open your Podfile, make your Podfile look like this one.
    • If you need to customize the path to node_modules, for example because you are using yarn workspaces, then you can pass in a param for this: use_unimodules!(modules_paths: ['./path/to/node_modules'])
  • Run pod install again
  • Update your AppDelegate.h and AppDelegate.m according to this diff.

Add permission usage description keys to Info.plist

In order to submit your app to the App Store, you will need to eventually add these keys to your Info.plist. Even if you don't use the APIs described, you need to include the keys because code related to asking the permission will be bundled regardless, and Apple's static analysis tools will detect it and reject your app if the key isn't present. Including the key without using it has no impact to your users - iOS app permissions are requested at runtime and not listed in the app store listing as they are on Android. Test the permission prompts and customize the message as needed.

<key>NSCalendarsUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your calendar</string>
<key>NSCameraUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use the camera</string>
<key>NSContactsUsageDescription</key>
<string>Allow $(PRODUCT_NAME) experiences to access your contacts</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your microphone</string>
<key>NSMotionUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your device's accelerometer</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Give $(PRODUCT_NAME) periences permission to save photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Give $(PRODUCT_NAME) periences permission to access your photos</string>
<key>NSRemindersUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your reminders</string>

Configure Android

  • Add apply from: '../node_modules/react-native-unimodules/gradle.groovy' and then includeUnimodulesProjects() to the top of android/settings.gradle
  • Add apply from: '../../node_modules/react-native-unimodules/gradle.groovy' anywhere in android/app/build.gradle and then addUnimodulesDependencies() inside dependencies {} block.
  • If you need to customize the path to node_modules, for example because you are using yarn workspaces, then you can pass in a param modulesPaths for both of these functions: includeUnimodulesProjects([modulesPaths: ['./path/to/node_modules']]), addUnimodulesDependencies([modulesPaths: ['./path/to/node_modules']])
  • You can also customize the configuration of the unimodules dependencies (the default is implementation, if you're using Gradle older than 3.0, you will need to set configuration: "compile" in addUnimodulesDependencies, like: addUnimodulesDependencies([configuration: "compile"]))
  • Update minSdkVersion in android/build.gradle to 21
  • Update your MainApplication.java to according to this diff.

Add permissions to AndroidManifest.xml

Add whichever of the following permissions you would like to use in your app to android/app/src/main:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />

API

It's possible that you will not have to use any of the code provided by this package directly, it may be used only by other Unimodules that you install.

But it's likely that you will want to use something like FileSystem or Permissions, and to do that you can import the following modules like so:

import {
  Asset,
  Constants,
  FileSystem,
  Permissions,
} from 'react-native-unimodules';

You can import them directly from the specific Unimodule packag if you like, but your linter may complain for import a transitive dependency.

import * as Permissions from 'expo-permissions';

react-native-unimodules's People

Contributors

brentvatne avatar sjchmiela avatar tsapeta avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.