Giter Club home page Giter Club logo

react-native-mob-sms's Introduction

react-native-mob-sms

React Native bridging library that integrates Mob-SMS

install

npm install @superhao/react-native-mob-sms --save

Android

Automatic

react-native link @superhao/react-native-mob-sms
  • Config
...

import com.superhao.react_native_mob_sms.MobSMS; // <--- IMPORT

public class MainActivity extends ReactActivity {

  ...
  
  @Override
  public void onCreate() {
    super.onCreate();
    ...
    MobSMS.init(this, "your-mob-appkey", "your-mob-appsecret"); // <--- ADD HERE
    ...
  }
  
  ...
}

Manually

  • android/settings.gradle
include ':react-native-mob-sms'
project(':react-native-mob-sms').projectDir = new File(rootProject.projectDir, '../node_modules/@superhao/react-native-mob-sms/android')
  • android/app/build.gradle
dependencies {
    compile project(':react-native-mob-sms')
}
  • register module (in MainActivity.java)
...

import com.superhao.react_native_mob_sms.MobSMSReactPackage; // <--- IMPORT
import com.superhao.react_native_mob_sms.MobSMS; // <--- IMPORT

public class MainActivity extends ReactActivity {

    ...

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new MobSMSReactPackage() // <--- ADD HERE
        );
    }
    
    ...
    
      @Override
  public void onCreate() {
    super.onCreate();
    ...
    MobSMS.init(this, "your-mob-appkey", "your-mob-appsecret"); // <--- ADD HERE
    ...
  }
}

iOS

Automatic

react-native link @superhao/react-native-mob-sms

Manually

Link AlipayModule library from your /node_modules/@superhao/react-native-mob-sms/ios folder like its described here. Don't forget to add it to "Build Phases" of project.

Config

  • Added the following libraries to your "Link Binary With Libraries":

    • libz
    • libicucore
    • libReactNativeMobSMS.a
    • JavaScriptCore.framework
    • SystemConfiguration.framework
    • CoreTelephony.framework
    • AdSupport.framework
    • AddressBook.framework
    • AddressBookUI.framework
  • ADD Your MOBAppKey and MOBAppSecret into Info.plist

<key>MOBAppSecret</key>
<string>Your-MOBAppSecret</string>
<key>MOBAppKey</key>
<string>Your-MOBAppKey</string>

File Not Found?

if you see error with #import <SMS_SDK/SMSSDK.h> #import <SMS_SDK/SMSSDKResultHandlerDef.h> #import <SMS_SDK/SMSSDKUserInfo.h> .... file not found, you can fix with "SMSSDK.h", "SMSSDKResultHandlerDef", "SMSSDKUserInfo"

General Usage

import {sendCode} from '@superhao/react-native-mob-sms';
sendCode('your-phone, 'your-zone', 'your-template').
  then((data)=>{
    if (Platform.OS === 'ios') {
      // show toast
      // this.refs.toast.show('验证码发送成功', 1500);
    }
  }).catch((error)=>{
       if (Platform.OS === 'ios') {
         // show toast
         // this.refs.toast.show('验证码发送失败', 1500);
       }
  });

react-native-mob-sms's People

Contributors

1556173267 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.