Skip to content

Commit

Permalink
Init library
Browse files Browse the repository at this point in the history
  • Loading branch information
Minishlink committed Sep 17, 2017
0 parents commit 27de180
Show file tree
Hide file tree
Showing 15 changed files with 543 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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Louis Lagrange

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.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# react-native-batch-push
> React Native integration of Batch.com push notifications SDK
## Getting started

`$ npm install react-native-batch-push --save`

### Mostly automatic installation

`$ react-native link react-native-batch-push`

### 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-batch-push` and add `RNBatchPush.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNBatchPush.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 tech.bam.RNBatchPush.RNBatchPushPackage;` to the imports at the top of the file
- Add `new RNBatchPushPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
include ':react-native-batch-push'
project(':react-native-batch-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-batch-push/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-batch-push')
```


## Usage
```javascript
import RNBatchPush from 'react-native-batch-push';

// TODO: What to do with the module?
RNBatchPush;
```

35 changes: 35 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
buildscript {
repositories {
jcenter()
}

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

apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

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

repositories {
mavenCentral()
}

dependencies {
compile 'com.facebook.react:react-native:+'
}

5 changes: 5 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tech.bam.RNBatchPush">

</manifest>

21 changes: 21 additions & 0 deletions android/src/main/java/tech/bam/RNBatchPush/RNBatchPushModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package tech.bam.RNBatchPush;

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 RNBatchPushModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;

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

@Override
public String getName() {
return "RNBatchPush";
}
}
27 changes: 27 additions & 0 deletions android/src/main/java/tech/bam/RNBatchPush/RNBatchPushPackage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package tech.bam.RNBatchPush;

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 RNBatchPushPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RNBatchPushModule(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 { RNBatchPush } = NativeModules;

export default RNBatchPush;
9 changes: 9 additions & 0 deletions ios/RNBatchPush.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 RNBatchPush : NSObject <RCTBridgeModule>

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

@implementation RNBatchPush

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

@end
23 changes: 23 additions & 0 deletions ios/RNBatchPush.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Pod::Spec.new do |s|
s.name = "RNBatchPush"
s.version = "1.0.0"
s.summary = "RNBatchPush"
s.description = <<-DESC
RNBatchPush
DESC
s.homepage = "https://github.com/bamlab/react-native-batch-push"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "author" => "[email protected]" }
s.platform = :ios, "7.0"
s.source = { :git => "https://github.com/bamlab/react-native-batch-push.git", :tag => "master" }
s.source_files = "RNBatchPush/**/*.{h,m}"
s.requires_arc = true


s.dependency "React"
#s.dependency "others"

end


Loading

0 comments on commit 27de180

Please sign in to comment.