Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dejan9393 committed Mar 8, 2019
0 parents commit 0a41147
Show file tree
Hide file tree
Showing 13 changed files with 504 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# OSX
#
.DS_Store

# node.js
#
node_modules/
npm-debug.log
yarn-error.log


# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace


# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# BUCK
buck-out/
\.buckd/
*.keystore
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# react-native-test-flight

## Getting started

`$ yarn add react-native-test-flight`

### Mostly automatic installation

`$ react-native link react-native-test-flight`

### Manual installation


#### iOS

1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
2. Go to `node_modules``react-native-test-flight` and add `RNTestFlight.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNTestFlight.a` to your project's `Build Phases``Link Binary With Libraries`
4. Run your project (`Cmd+R`)<

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- Add `import com.reactlibrary.RNTestFlightPackage;` to the imports at the top of the file
- Add `new RNTestFlightPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-test-flight'
project(':react-native-test-flight').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-test-flight/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-test-flight')
```

## Usage
```javascript
import RNTestFlight from 'react-native-test-flight';

if (RNTestFlight.isTestFlight) {
console.log("Ground control to Major Tom");
}
```
34 changes: 34 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}

repositories {
mavenCentral()
}

dependencies {
compile 'com.facebook.react:react-native:+'
}
4 changes: 4 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactlibrary">

</manifest>
29 changes: 29 additions & 0 deletions android/src/main/java/com/reactlibrary/RNTestFlightModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.reactlibrary;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;

public class RNTestFlightModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;

public RNTestFlightModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}

@Override
public String getName() {
return "RNTestFlight";
}

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put(isTestFlight, Toast.LENGTH_SHORT);

return constants;
}
}
27 changes: 27 additions & 0 deletions android/src/main/java/com/reactlibrary/RNTestFlightPackage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.reactlibrary;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
public class RNTestFlightPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RNTestFlightModule(reactContext));
}

// Deprecated from RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {NativeModules} from 'react-native';

const {RNTestFlight} = NativeModules;

export default RNTestFlight;
9 changes: 9 additions & 0 deletions ios/RNTestFlight.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

@interface RNTestFlight : NSObject <RCTBridgeModule>

@end
21 changes: 21 additions & 0 deletions ios/RNTestFlight.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#import "RNTestFlight.h"

@implementation RNTestFlight

- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}

RCT_EXPORT_MODULE()

- (NSDictionary *)constantsToExport
{
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSString *receiptURLString = [receiptURL path];
BOOL isRunningTestFlightBeta = ([receiptURLString rangeOfString:@"sandboxReceipt"].location != NSNotFound);

return @{ @"isTestFlight" : @(isRunningTestFlightBeta) };
};

@end
Loading

0 comments on commit 0a41147

Please sign in to comment.