Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
First attempt with pseudo code
Browse files Browse the repository at this point in the history
  • Loading branch information
martincik committed Jan 10, 2016
0 parents commit b315074
Show file tree
Hide file tree
Showing 13 changed files with 510 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# OSX
#
.DS_Store

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

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

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
img
example
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Apptailor

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# react-native-hockeyapp
[HockeyApp](http://hockeyapp.com) integration for React Native.

## Requirements

- iOS 7+
- Android
- React Native >0.14
- CocoaPods

## Installation

```bash
npm install react-native-hockeyapp --save
```

## iOS

You will need:

CocoaPods ([Setup](https://guides.cocoapods.org/using/getting-started.html#installation))

### Podfile

Add to your `ios/Podfile`:
```ruby
pod "HockeySDK"
```


## Android

### Google project configuration

* In `android/setting.gradle`

```gradle
...
include ':react-native-hockeyapp', ':app'
project(':react-native-hockeyapp').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-hockeyapp/android')
```

* In `android/build.gradle`

```gradle
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'net.hockeyapp.android:HockeySDK:3.0.2' // <--- add this
}
```

* In `android/app/build.gradle`

```gradle
apply plugin: "com.android.application"
apply plugin: 'net.hockeyapp.android:HockeySDK' // <--- add this at the TOP
...
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.14.+"
compile project(":react-native-hockeyapp") // <--- add this
}
```

* Manifest file
```xml
<activity android:name="net.hockeyapp.android.UpdateActivity" />
```

* Register Module (in MainActivity.java)

```java
import com.slowpath.hockeyapp.RNHockeyAppModule; // <--- import
import com.slowpath.hockeyapp.RNHockeyAppPackage; // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);

mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new RNHockeyAppPackage(this)) // <------ add this line to yout MainActivity class
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();

mReactRootView.startReactApplication(mReactInstanceManager, "AndroidRNSample", null);

setContentView(mReactRootView);
}
......

}
```


# Usage

From your JS files for both iOS and Android:

```js
var HockeyApp = require('react-native-hockeyapp');

HockeyApp.configure(HOCKEY_KEY);
// or turn off auto send crash reports
HockeyApp.configure(HOCKEY_KEY, false);
```

17 changes: 17 additions & 0 deletions RNHockeyApp/RNHockeyApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef RN_HockeyApp_h
#define RN_HockeyApp_h

#import "RCTBridgeModule.h"
#import <HockeySDK/HockeySDK.h>

@interface RNHockeyApp : NSObject<RCTBridgeModule> {
BOOL initialized;
NSString *token;
BOOL autoSend;
}

+ (BOOL)applicationDidFinishLaunching;

@end

#endif
69 changes: 69 additions & 0 deletions RNHockeyApp/RNHockeyApp.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#import "RNHockeyApp.h"
#import "RCTEventDispatcher.h"

@implementation RNHockeyApp

- (id)init
{
self = [super init];
initialized = NO;
autoSend = YES;
return self;
}

RCT_EXPORT_MODULE();

@synthesize bridge = _bridge;

RCT_EXPORT_METHOD(configure:(NSString *) apiToken autoSend:(BOOL) autoSendCrashes)
{
if (initialized == NO)
autoSend = autoSendCrashes;
token = apiToken;
initialized = YES;
}
}

RCT_EXPORT_METHOD(start:(NSString *) token)
{
[self start:token autoSend:YES];
}

RCT_EXPORT_METHOD(feedback)
{
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager].feedbackManager showFeedbackListView];
}
}

RCT_EXPORT_METHOD(checkForUpdate)
{
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager].updateManager checkForUpdate];
}
}

RCT_EXPORT_METHOD(generateTestCrash)
{
[[BITHockeyManager sharedHockeyManager].crashManager generateTestCrash];
}

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

+ (BOOL)applicationDidFinishLaunching {
if (initialized == YES) {
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:token];
if (autoSend == YES) {
[[BITHockeyManager sharedHockeyManager].crashManager setCrashManagerStatus:BITCrashManagerStatusAutoSend];
}
[[BITHockeyManager sharedHockeyManager] startManager];
[[BITHockeyManager sharedHockeyManager].authenticator authenticateInstallation];
}

return YES;
}

@end
23 changes: 23 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.facebook.react:react-native:0.14.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.2'
}
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.slowpath.hockeyapp">
</manifest>
Loading

0 comments on commit b315074

Please sign in to comment.