shareinstall_rn

    1.0.7 • Public • Published

    shareinstall_rn

    Getting started(安装)

    $ npm install shareinstall_rn --save

    Mostly automatic installation(连接)

    $ react-native link shareinstall_rn

    Manual installation

    iOS

    1.把node_modules/shareinstall_rn/ios 路径下shareinstall文件夹拖入ios工程

    2.在ios工程buile settings里面的Framework Search Paths里面配置framework路径,例如$(PROJECT_DIR)/../node_modules/shareinstall_rn/ios/shareinstall

    3.在ios工程buile settings里面的other linker flags里面添加-ObjC

    4.在ios工程info.plist文件中配置appKey键值对,如下:

    <key>com.shareinstall.APP_KEY</key>
    <string>shareinstall分配给应用的appkey</string>)
    

    5.其余配置请参考shareinstall官网

    6.appdelegate代码接入

    #import "RNShareinstall.h"
    #import <ShareInstallSDK/ShareInstallSDK.h>
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
      ...
      [ShareInstallSDK initWithDelegate:[RNShareinstall allocWithZone:nil] withOptions:launchOptions];
      ...
    }
    //ios9以下 URI Scheme
    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
      //判断是否通过ShareInstall URL Scheme 唤起App
      if ([RNShareinstall schemeUrlHandler:url]) {
        return YES;
      }else{
        //其他代码
        return YES;
      }
    }
    

    //iOS9以上 URL Scheme

    - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(nonnull NSDictionary *)options
    {
      //判断是否通过ShareInstall URL Scheme 唤起App
      if ([RNShareinstall schemeUrlHandler:url]) {
        return YES;
      }else{
        //其他代码
        return YES;
      }
    }
    

    //Universal Links 通用链接

    - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
    {
      //判断是否通过ShareInstall Universal Links 唤起App
      if ([RNShareinstall universalLinkHandler:userActivity]) {
        return YES ;
      }else{
        //其他代码
        return YES;
      }
      
    }
    

    Android

    1. Open up android/app/src/main/java/[...]/MainActivity.java
    • Add import com.shareinstall.shareinstallibrary.RNShareinstallPackage; to the imports at the top of the file
    • Add new RNShareinstallPackage() to the list returned by the getPackages() method
    1. Append the following lines to android/settings.gradle:
      include ':shareinstall_rn'
      project(':shareinstall_rn').projectDir = new File(rootProject.projectDir,   '../node_modules/shareinstall_rn/android')
      
    2. Insert the following lines inside the dependencies block in android/app/build.gradle:
        compile project(':shareinstall_rn')
      
    3. 配置唤醒scheme
     <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="agec3112" /> //shareinstall后台分配的scheme
     </intent-filter>
    
    1. 在application里配置appkey
     <meta-data
          android:name="com.shareinstall.APP_KEY"
          android:value="F2BK2K6F7BBAAR" /> //shareinstall后台分配的appkey
      ```
    
    
    ## Usage
    ```javascript
    import RNShareinstall from 'shareinstall_rn';
    
    // TODO: What to do with the module?
    RNShareinstall;
    

    //获取安装参数 RNShareinstall.getInstall((result)=>{ console.log('install>>info>>>',JSON.parse(result)); })

    //获取唤醒参数 RNShareinstall.addWakeUpListener((result)=>{ console.log('wakeup>>info>>>',JSON.parse(result)); })

    //注册上报 RNShareinstall.reportRegister();

    Keywords

    Install

    npm i shareinstall_rn

    DownloadsWeekly Downloads

    0

    Version

    1.0.7

    License

    none

    Unpacked Size

    10.3 MB

    Total Files

    56

    Last publish

    Collaborators

    • shareinstall