0.0.92 • Published 1 year ago

react-native-lnssh v0.0.92

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React Native Lnssh (mobile)

A lnssh for react-native, hide when application loaded

Installation

npm install react-native-lnssh --save

Installation (iOS pod install)

  • cd ios
  • 在 Podfile 文件上添加 pod 'WHToast','~>0.1.0' pod 'MBProgressHUD', '~> 1.2.0'
  • pod install

  • In AppDelegate.m

...
#import <Lnssh/LnsshManager.h> //<--- import
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"KitchenSink"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [[UIViewController alloc] init];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [LnsshManager show:rootView]; //<--- add show SplashScreen
  
  return YES;
  • In Info.plis
添加 Privacy - Photo Library Additions Usage Description,
Privacy - Photo Library Additions Usage ,DescriptionNSPhotoLibraryUsageDescription ,
PHAuthorizationStatusLimited 权限

Installation (Android) old version < 0.60

...
include ':react-native-lnssh'
project(':react-native-lnssh').projectDir = new File(settingsDir, '../node_modules/react-native-lnssh/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    implementation project(':react-native-lnssh')
}
  • register module (in MainApplication.java)
......
import com.lnssh.LnsshPackage;  // <--- import

......

@Override
protected List<ReactPackage> getPackages() {
   ......
   new LnsshPackage(),            // <------ add here [the seconde params is translucent]
   ......
}
  • register module (in MainActivity.java)
public class MainActivity extends ReactActivity {
    public static Activity activity;           // <------ add 
    public LnsshManager lnsshmanager; // <------ add here
    ......
    @Override
    protected String getMainComponentName() {
        activity = this;    // <------ add here
        lnsshmanager=new LnsshManager(this);  // <------ add here
       lnsshmanager.splash_show(R.drawable.splash);// <------ 如果设置启动页 add here
    
       ......
    }
}
  • set permission (in AndroidManifest.xml)
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_DOWNLOAD_MANAGER"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  • add networkSecurityConfig (in AndroidManifest.xml)
<application
.....
android:networkSecurityConfig="@xml/network_security_config"
...
/>
  • add file_paths(in AndroidManifest.xml)
<provider
		android:name="androidx.core.content.FileProvider"
		android:authorities="${ApplicationId}.fileprovider"
		android:exported="false"
		android:grantUriPermissions="true">
		<meta-data
			android:name="android.support.FILE_PROVIDER_PATHS"
			android:resource="@xml/file_paths" />
	</provider>
  • in file_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
	<root-path name="root" path="/" />
	......
	<files-path name="app_down" path="/lnssh/apk/" />   //<----add here
	<files-path name="share_files" path="/lnssh/record/" />  //<----add here
</paths>
  • in network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
	<base-config cleartextTrafficPermitted="true" />
</network-security-config>
* Copy lines to proguard-rules.pro:
```java
-keep class com.tencent.mm.sdk.** {
  *;
}
*Integrating with login and share

If you are going to integrate login or share functions, you need to create a package named 'wxapi' in your application package and a class named WXEntryActivity in it.

```java 
package com.lnssh.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.theweflex.react.WeChatModule;

public class WXEntryActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WeChatModule.handleIntent(getIntent());
    finish();
  }
}
* Then add the following node to AndroidManifest.xml:

```java 
<manifest>
  <application>
    <activity
      android:name=".wxapi.WXEntryActivity"
      android:label="@string/app_name"
      android:exported="true"
    />
  </application>
</manifest>
*Integrating the WeChat Payment

If you are going to integrate payment functionality by using this library, then create a package named also wxapi in your application package and a class named WXPayEntryActivity, this is used to bypass the response to JS level:
```java 
package your.package.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.theweflex.react.WeChatModule;

public class WXPayEntryActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WeChatModule.handleIntent(getIntent());
    finish();
  }
}
*Then add the following node to AndroidManifest.xml:
```java 
<manifest>
  <application>
    <activity
      android:name=".wxapi.WXPayEntryActivity"
      android:label="@string/app_name"
      android:exported="true"
    />
  </application>
</manifest>

Usage

Example

'use strict';
var React = require('react');
var ReactNative = require('react-native');
import LnsshManager from "react-native-lnssh";
var {LnsshModule,myImagePicker,WeChat,UpdateManager,permissionSetting} = LnsshManager;

var {
    AppRegistry,
    View,
    Text,
    NativeModules
} = ReactNative;


var KitchenSink = React.createClass({
    componentDidMount: function() {
       LnsshModule.splash_hide();
      WeChat.registerApp('appid');
      WeChat.openWXApp();
    },
    render() {
        return(
            <View>
                <Text>
                    fangyunjiang is a good developer!
                </Text>
            </View>
        );
    }
});

AppRegistry.registerComponent('KitchenSink', () => KitchenSink);
0.0.92

1 year ago

0.0.91

2 years ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.90

2 years ago

0.0.84

3 years ago

0.0.80

3 years ago

0.0.81

3 years ago

0.0.82

3 years ago

0.0.83

3 years ago

0.0.75

3 years ago

0.0.76

3 years ago

0.0.77

3 years ago

0.0.78

3 years ago

0.0.79

3 years ago

0.0.73

3 years ago

0.0.74

3 years ago

0.0.70

3 years ago

0.0.71

3 years ago

0.0.72

3 years ago

0.0.65

3 years ago

0.0.66

3 years ago

0.0.67

3 years ago

0.0.68

3 years ago

0.0.69

3 years ago

0.0.45

3 years ago

0.0.46

3 years ago

0.0.47

3 years ago

0.0.62

3 years ago

0.0.63

3 years ago

0.0.64

3 years ago

0.0.60

3 years ago

0.0.61

3 years ago

0.0.59

3 years ago

0.0.51

3 years ago

0.0.52

3 years ago

0.0.53

3 years ago

0.0.54

3 years ago

0.0.55

3 years ago

0.0.56

3 years ago

0.0.57

3 years ago

0.0.58

3 years ago

0.0.50

3 years ago

0.0.48

3 years ago

0.0.49

3 years ago

0.0.44

3 years ago

0.0.43

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.40

3 years ago

0.0.39

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago