Giter Club home page Giter Club logo

Comments (12)

babariviere avatar babariviere commented on July 23, 2024

Hello,
You can't do that for now, we are working on it, sorry

from flutter_sms.

nitneuq33000 avatar nitneuq33000 commented on July 23, 2024

from flutter_sms.

babariviere avatar babariviere commented on July 23, 2024

@nitneuq33000 We have implemented the feature, you can test it like that:

  SmsSender sender = new SmsSender();
  String address = getAddress();
  ...
  SmsMessage message = new SmsMessage(address, 'Hello flutter!');
  message.addStateListener((state) {
  if (state == SmsMessageState.Sent) {
    print("SMS is sent!");
  } else if (state == SmsMessageState.Delivered) {
    print("SMS is delivered!");
  }
});
sender.sendSms(message);

from flutter_sms.

nitneuq33 avatar nitneuq33 commented on July 23, 2024

@babariviere I tried, I upload pubspec.yaml

I have an error with getAdress () (no defined methode ) so I change the code like this

SmsSender sender = new SmsSender();
...
SmsMessage message = new SmsMessage(+33---------, 'Hello flutter!');
message.addStateListener((state) {
if (state == SmsMessageState.Sent) {
print("SMS is sent!");
} else if (state == SmsMessageState.Delivered) {
print("SMS is delivered!");
}
});
sender.sendSms(message);

I have this error message:

compiler message: lib/SecondPage.dart:181:38: Error: Getter not found: 'SmsMessageState'.
compiler message: if (state == SmsMessageState.Sent) {
compiler message: ^^^^^^^^^^^^^^^
compiler message: lib/SecondPage.dart:183:45: Error: Getter not found: 'SmsMessageState'.
compiler message: } else if (state == SmsMessageState.Delivered) {
compiler message: ^^^^^^^^^^^^^^^
compiler message: lib/SecondPage.dart:180:31: Error: The method 'addStateListener' isn't defined for the class 'sms::SmsMessage'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'addStateListener'.
compiler message: message.addStateListener((state) {
compiler message: ^
compiler message: lib/SecondPage.dart:181:38: Error: The getter 'SmsMessageState' isn't defined for the class '#lib1::_MyAppState'.
compiler message: Try correcting the name to the name of an existing getter, or defining a getter or field named 'SmsMessageState'.
compiler message: if (state == SmsMessageState.Sent) {
compiler message: ^
compiler message: lib/SecondPage.dart:183:45: Error: The getter 'SmsMessageState' isn't defined for the class '#lib1::_MyAppState'.
compiler message: Try correcting the name to the name of an existing getter, or defining a getter or field named 'SmsMessageState'.
compiler message: } else if (state == SmsMessageState.Delivered) {
compiler message:

from flutter_sms.

babariviere avatar babariviere commented on July 23, 2024

getAddress() is not in the library, you have to put your own address

from flutter_sms.

babariviere avatar babariviere commented on July 23, 2024

It's a string so you have to put it between "

from flutter_sms.

nitneuq33 avatar nitneuq33 commented on July 23, 2024

sorry I'm a noob ^^ I tried to put my number +336------- everywhere

String address = ("+336------");
String address = "+336------";
String address = "06--------";
...

and I have all the time this error

compiler message: lib/SecondPage.dart:181:38: Error: Getter not found: 'SmsMessageState'.
compiler message: if (state == SmsMessageState.Sent) {
compiler message: ^^^^^^^^^^^^^^^
compiler message: lib/SecondPage.dart:183:45: Error: Getter not found: 'SmsMessageState'.
compiler message: } else if (state == SmsMessageState.Delivered) {
compiler message: ^^^^^^^^^^^^^^^
compiler message: lib/SecondPage.dart:180:31: Error: The method 'addStateListener' isn't defined for the class 'sms::SmsMessage'.
compiler message: Try correcting the name to the name of an existing method, or defining a method named 'addStateListener'.
compiler message: message.addStateListener((state) {
compiler message: ^
compiler message: lib/SecondPage.dart:181:38: Error: The getter 'SmsMessageState' isn't defined for the class '#lib1::_MyAppState'.
compiler message: Try correcting the name to the name of an existing getter, or defining a getter or field named 'SmsMessageState'.
compiler message: if (state == SmsMessageState.Sent) {
compiler message: ^
compiler message: lib/SecondPage.dart:183:45: Error: The getter 'SmsMessageState' isn't defined for the class '#lib1::_MyAppState'.
compiler message: Try correcting the name to the name of an existing getter, or defining a getter or field named 'SmsMessageState'.
compiler message: } else if (state == SmsMessageState.Delivered) {
compiler message:

if you have a simple example where I can put my number, it will be perfect :) sorry for my bad level

here is my configuration
[√] Flutter (Channel beta, v0.2.8, on Microsoft Windows [version 10.0.16299.309], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.0)
[√] VS Code, 64-bit edition (version 1.21.1)
[√] Connected devices (1 available)

β€’ No issues found!

I tried to add : " Function(SmsMessageState) addStateListener;" in sms.dart pluggin but I y always error: line 181 pos 31: lib/SecondPage.dart:181:31: Error: The method 'addStateListener' isn't defined for the class 'sms::SmsMessage'.

from flutter_sms.

joanpablo avatar joanpablo commented on July 23, 2024

@nitneuq33
Did you update to the latest package version (0.1.0) in your pubspec.yaml file?

  flutter:
    sdk: flutter

  sms: ^0.1.0

from flutter_sms.

nitneuq33 avatar nitneuq33 commented on July 23, 2024

from flutter_sms.

babariviere avatar babariviere commented on July 23, 2024

I think you have to run flutter update or something like that to update all dependencies

from flutter_sms.

nitneuq33 avatar nitneuq33 commented on July 23, 2024

It's ok after flutter upgrade :) thank you. I tried a simple code and yes it's print my SMS after received. but now I want to treat the received message. how to extract le string message ? I tried to create a variable like var X = msg; or string X = msg; but msg isn't defined. I also tried to use _smsSubscription = _receiver.onSmsReceived.listen((SmsMessage msg) => _lastMessage = msg) but _lastMessage return :"instance of 'SMSMessage'. thank you for all

from flutter_sms.

babariviere avatar babariviere commented on July 23, 2024

You can use message.body πŸ˜ƒ

from flutter_sms.

Related Issues (20)

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.