Giter VIP home page Giter VIP logo

react-native-sms-x's Introduction

react-native-sms-x


SendSMS

A react-native api to send SMS messages. It works only for android. This component used android native api to send sms and response a callback to react-native. This react-native component doesn't link to the mobile default messenger view. It will programmatically send the message to a phone number which is provided as a parameter and will response a callback with a string indicating message was sent or failure or no service.

usage

import SendSMS from 'react-native-sms-x';
// you can put any number as Id to identify which message being process
SendSMS.send(123, "+959254687254", "Hey.., this is me!\nGood to see you. Have a nice day.", (msgId, msg) => {
    console.log(`message ID: ${msgId}, message: ${msg}`);
    // Output if successfull: message ID: 123, message: SMS sent
});

Response msg string will be one of the following:

  • "SMS sent" - for successful message
  • "Generic failure" - for general failure
  • "No service" - for no mobile operator service
  • "Radio off" - for no mobile signal
  • "Null PDU" - for no PDU
Note:
Minimum android version is 4.1 and supported RN >= v0.29.

Installation

npm install react-native-sms-x --save

Android Setup

1.In your android/settings.gradle file, make the following additions:

include ':react-native-sms-x'
project(':react-native-sms-x').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sms-x/android/app')

2.In your android/app/build.gradle file, add the ':react-native-sms-x' project as a compile-time dependency:

...
dependencies {
    ...
    compile project(':react-native-sms-x')
}

3.Update the MainApplication.java file as follow:

import com.facebook.react.ReactApplication;
...
import com.someone.sendsms.SendSMSPackage; // <--- add here!


public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new SendSMSPackage()     // <--- add here!
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

4.In your AndroidManifest.xml file, add a user permission for sending SMS.

<uses-permission android:name="android.permission.SEND_SMS" />

Example

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableOpacity,
  ToastAndroid
} from 'react-native';
import SendSMS from 'react-native-sms-x';

export default class RNSMS extends Component {
  sendSMSFunction() {
    SendSMS.send(123, "+95912345678", "Hey.., this is me!\nGood to see you. Have a nice day.",
      (msgId, msg)=>{
        ToastAndroid.show(msg, ToastAndroid.SHORT);
      }
    );
  }
  render() {
    return (
      <View style={styles.container}>        
        <TouchableOpacity style={styles.button} onPress={this.sendSMSFunction.bind(this)}>
          <Text>Send SMS</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },  
  button: {
    padding: 10,
    borderWidth: .5,
    borderColor: '#bbb',
    margin: 10,
    alignItems: 'center',
    justifyContent: 'center'
  }
});

AppRegistry.registerComponent('RNSMS', () => RNSMS);

Support on Beerpay

Hey dude! Help me out for a couple of 馃嵒!

Beerpay Beerpay

react-native-sms-x's People

Contributors

arbo77 avatar liamirali avatar yeyintkoko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-sms-x's Issues

'compile' is obsolete (will be removed on Gradle 7.0)

When I try to build my app for android, I get the following warning:

> Configure project :react-native-sms-x
WARNING:: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

I guess this line is causing the problem:

compile "com.facebook.react:react-native:+" // From node_modules.

java.lang.Double cannot be cast to java.lang.String

Hello!
I am testing the component and using the suggested example, just changing my phone number. But, the error "java.lang.Double cannot be cast to java.lang.String" occurs. I looked for some solution on Google but I didn't find anything that I could apply to solve it in use with "react-native-sms-x". Can anybody help me?

This is my code:
request(PERMISSIONS.ANDROID.SEND_SMS).then(result => {
SendSMS.send(
123,
'+55<my_number>',
'Hey.., this is me!\nGood to see you. Have a nice day.',
msg => {
ToastAndroid.show(msg, ToastAndroid.SHORT);
},
);
});

Sdk version 31 above S+

On apps with compileSdkVersion above 31, this error will be thrown when trying to send an SMS:

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Sms not showing in the conversation list

Hi guys, thanks for the package,
It's working on most the devices I tried but on this huawei y6 with android 9 it's sending the message, another phone is receiving it, but unfortunately it doesn't show up on the message list on the sms app.

also when someone replies to the message, i don't get any text.
any idea?

Important: Update package on npm

Please merge the open pull requests and update the package on npm so we can update the package with ease from the npm repository.

People are forced to publish their own repositories due to the open abandoned PRs and issues. It's important to have one centralized package instead of having one separate package for each of the users.

If I see no activity on this repo for a long, I will have to publish a new package with the open PRs merged.

react-native-sms-x:compileReleaseJavaWithJavac

hey
i get this error after install the package

node_modules\react-native-sms-x\android\app\src\main\java\com\someone\sendsms\SendSMSPackage.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
1 error
:react-native-sms-x:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-sms-x:compileReleaseJavaWithJavac'.

what was wrong?
Window 10 , RN 48.4

Does this still work ?

I am attempting to install this but SmsManager is no longer available ? can anyone confirm or provide an alternative resuource to send sms from background?

Thanks.

undefined is not an object(evaluating '_reactNativeSmsX.default.send')

Hi everyone I get this error when I click sends SMS button.

sendSMSFunction() {
    SendSMS.send(123, "+95912345678", "Hey.., this is me!\nGood to see you. Have a nice day.",
      (msg)=>{
        ToastAndroid.show(msg, ToastAndroid.SHORT);
      }
    );
  }

i am using code from example.
Thanks
react-native-cli: 2.0.1
react-native: 0.57.3

screenshot_20181024-143252_sms

Build fails when using react-native-x.

Hi,

When i use your lib i get

A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-sms-x'.
   > failed to find Build Tools revision 24.0.1

I tried to check if everything was okay and it was as how you recommended in README (double checked).

I can't really figure out what's wrong but i thought i should let you know about this.

Thanks.

Build fails when using SDK Version 28

I have a lot of errors related with compileSdkVersion and buildToolsVersion

error: style attribute 'android:attr/colorError not found' not found.
error: style attribute 'android:attr/keyboardNavigationCluster' not found.
error: resource android:attr/dialogCornerRadius not found.
...

this issue was resolved by adding the following lines in your android/build.gradle file

allprojects {
    ...
    subprojects {
        afterEvaluate {
            project ->
                if (project.hasProperty("android")) {
                    android {
                        compileSdkVersion 28
                        buildToolsVersion '28.0.3'
                    }
                }
        }
    }
}

Error: Duplicate module name

Hi, after installed react-native-sms-x, when run npm start, this error returns

root@developer1:/var/www/html/senderfy# npm start

[email protected] start /var/www/html/senderfy
react-native-scripts start

14:43:30: Starting packager...
ERROR STARTING PACKAGER
Starting React Native packager...
Scanning folders for symlinks in /var/www/html/senderfy/node_modules (15ms)
Loading dependency graph.

jest-haste-map: @providesModule naming collision:
Duplicate module name: react-native
Paths: /var/www/html/senderfy/node_modules/react-native-sms-x/node_modules/react->native/package.json collides with /var/www/html/senderfy/node_modules/react-native/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.

Message does not have permission SEND_SMS

I added the

to the AndroidManifest.xml
But I stll get this message - Snding SMS message: uid 10216 does not have android.premission.SEND_SMS.
Why is that?
Should I add anything else to manifest? Or anything else I am missing?

Packager fails to build upon npm install

So I installed this package into my app and after it finished installing from npm and I start react-native packager I get the following errors without making the changes in the android folder. The problem persists even after making the changes in the android folder that were instructed from the readme. Here are the errors:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/kennetpostigo/Projects/react-native/node_modules/react-native-sms-x/node_modules/react-native/local-cli/core/__fixtures__/files/package.json colli
ative/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
  Duplicate module name: react-native-vector-icons
  Paths: /Users/kennetpostigo/Projects/react-native/node_modules/react-native-sms-x/node_modules/react-native/local-cli/core/__fixtures__/files/package.json colli
ative/node_modules/react-native/local-cli/core/__fixtures__/files/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (/Users/kennetpostigo/Projects/react-native/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:159:13)
    at p.getName.then.name (/Users/kennetpostigo/Projects/react-native/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:134:31)

Do you know why this occurs?

SMS sending failed dua to larger size

I am having issues while sending lengthy messages through react-native-sms-x. The plugin works perfectly when dealing with small messages. but when I send lengthy SMS through the app. The app doesn't show any error but also not send SMS.

Expo setup

Can i setup this package with Expo? i get error: Typerror:null is not an object(evaluating '_reactNativeGetSmsX.default.send')

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.