Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-branch

Package Overview
Dependencies
Maintainers
2
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-branch - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

android/build.gradle

12

index.js

@@ -1,9 +0,15 @@

var { NativeModules, NativeAppEventEmitter } = require('react-native');
var { NativeModules, NativeAppEventEmitter, DeviceEventEmitter, Platform } = require('react-native');
var rnBranch = NativeModules.RNBranch;
// According to the React Native docs from 0.21, NativeAppEventEmitter is used for native iOS modules to emit events. DeviceEventEmitter is used for native Android modules.
// Both are technically supported on Android -- but I chose to follow the suggested route by the documentation to minimize the risk of this code breaking with a future release
// in case NativeAppEventEmitter ever got deprecated on Android
const nativeEventEmitter = Platform.OS === 'ios' ? NativeAppEventEmitter : DeviceEventEmitter;
class Branch {
constructor() {
//We listen to the initialization event AND retrieve the result to account for both scenarios in which the results may already be available or be posted at a later point in time
NativeAppEventEmitter.addListener('RNBranch.initSessionFinished', this._onReceivedInitSessionResult);
nativeEventEmitter.addListener('RNBranch.initSessionFinished', this._onReceivedInitSessionResult);
this._getInitSessionResult((result) => {

@@ -40,3 +46,3 @@ if(!result) { //Not available yet => will come through with the initSessionFinished event

setDebug = () => {
setDebug = () => {
rnBranch.setDebug();

@@ -43,0 +49,0 @@ };

{
"name": "react-native-branch",
"version": "0.0.2",
"version": "0.0.3",
"description": "Native Wrapper around Branch Metrics native SDKs",

@@ -5,0 +5,0 @@ "main": "index.js",

# react-native-branch
Native Wrapper around Branch Metrics native SDKs. Tested with React Native 0.18.1 and branch 0.11.14.
Native Wrapper around Branch Metrics native SDKs. Tested with React Native 0.21.0.
Android support to come shortly.
Supports iOS and Android.

@@ -29,8 +29,101 @@ ## Usage

cd node_modules/react-native-branch
pod install
pod install #Only required for iOS
```
### Android
#### Step 0 - Verify Library Linking
*Sometimes rnpm link creates incorrect relative paths, leading to compilation errors*
*Ensure that the following files look as described and all linked paths are correct*
```gradle
// file: android/settings.gradle
...
include ':react-native-branch', ':app'
// The relative path to the react-native-branch directory tends to often be prefixed with one too many "../"s
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
```
```gradle
// file: android/app/build.gradle
...
dependencies {
...
compile project(':react-native-branch')
}
```
#### Step 1 - Initialize the RNBranchModule
```java
// file: android/app/src/main/java/com/xxx/MainActivity.java
import android.content.Intent; // <-- import
import com.dispatcher.rnbranch.*; // <-- import
public class MainActivity extends ReactActivity {
// ...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNBranchPackage() // <-- add this line, if not already there
);
}
// Add onStart
@Override
public void onStart() {
super.onStart();
RNBranchModule.initSession(this.getIntent().getData(), this);
}
// Add onNewIntent
@Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
// ...
}
```
#### Step 2 - Configure Manifest
Please follow [these instructions] (https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/#configure-manifest)
#### Step 3 - Register for Google Play Install Referrer
Please follow [these instructions](https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/#register-for-google-play-install-referrer)
Note: The "receiver" element needs to be added to the "application" node in AndroidManifest.xml
#### Step 4 - Register a URI scheme
Please follow [these instructions](https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/#register-a-uri-scheme)
Notes:
- The "intent-filter" element needs to be added to the activity node, whose android:name is "com.yourAppName.MainActivity". This node is in the "application" node.
- Make sure to replace "yourApp" with the scheme you specified in the Branch dashboard.
#### Step 5 - Enable Auto Session Management
Please follow [these instructions](https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/#enable-auto-session-management)
Note: Just add the "android:name" attribute to your "application" node in your AndroidManifest.xml
#### Step 6 - Enable App Links for Android M and above (Optional but Recommended)
Please follow [these instructions](https://dev.branch.io/getting-started/universal-app-links/guide/android/)
### iOS
#### Modifications to your React Native XCode Project
#### Step 1 - Modifications to your React Native XCode Project

@@ -42,3 +135,3 @@ - Drag and Drop /node_modules/react-native-branch/Pods/Pods.xcodeproj into the Libraries folder of your project in XCode (as described in Step 1 [here](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content))

#### Modifications to AppDelegate.m
#### Step 2 - Modifications to AppDelegate.m

@@ -79,12 +172,12 @@ Import RNBranch.h at the top

#### Add the branch_key to your plist
#### Step 3 - Add the branch_key to your plist
Add a String entry branch_key with your branch key to your plist (as described [here](https://dev.branch.io/references/ios_sdk/#add-your-branch-key-to-your-project))
#### Register a URI Scheme for Direct Deep Linking (Optional but Recommended)
#### Step 4 - Register a URI Scheme for Direct Deep Linking (Optional but Recommended)
Please follow these instructions [here](https://dev.branch.io/references/ios_sdk/#register-a-uri-scheme-direct-deep-linking-optional-but-recommended)
#### Configure for Universal Links
#### Step 5 - Configure for Universal Linking
Please follow these instructions [here](https://dev.branch.io/references/ios_sdk/#support-universal-linking-ios-9)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc