babariviere / flutter_sms Goto Github PK
View Code? Open in Web Editor NEWSMS library for flutter
License: MIT License
SMS library for flutter
License: MIT License
When we are trying to request more than one request, we got an error and permission request is skipped
hello, Actually when I send me an SMS I can print only the previous sms and not wait to receive the sms ( in transistion ) and print it when it's receive. how can I do that.
Hi, when i try to send an SMS i get this error:
AndroidRuntime(10682): Process: com.example.smsapp, PID: 10682
E/AndroidRuntime(10682): java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=2, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.example.smsapp/com.example.smsapp.MainActivity}: java.lang.SecurityException: Neither user 10279 nor current process has android.permission.READ_PHONE_STATE.
So for android 8 / Huawei Mate 9 i need to ask READ_PHONE_STATE over platform channels and then it works, but it would be better if the Plugin ask this Permission for me.
Thx
Library is great for querying, reading and sending messages but completely skipped deletion.
Also a broadcast receiver would be needed to show SMS notifications.
Could the SmsMessage.id
be used to access the content provider to remove the specific message?
Also was getting a deprecated notification for the Telephony Manager, not able to reproduce. Will add when I can.
This rewrite will make error handling better because of Kotlin features.
You can follow progress on https://github.com/babariviere/flutter_sms/commits/kotlin
Add all features to the example app.
Hi,
I'm sending SMS successfully, they are received by the recipient. I can't however query those back.
Here's my query:
List<SmsMessage> messages = await _query.querySms(threadId: threadID, kinds: [SmsQueryKind.Inbox, SmsQueryKind.Sent], sort: true);
print('CALLED === /// ');
for (SmsMessage msg in _messages) {
print(msg.body);
}
Any ideas?
Hi
I want to make a logo for this projects if you have any requirements then let me know.its totally free for open source projects.
When sending using the 1st sim slot, the code bellow works.
SmsSender sender = new SmsSender();
SimCardsProvider provider = new SimCardsProvider();
card = await provider.getSimCards();
SmsMessage message = new SmsMessage("address", "content");
sender.sendSms(message, simCard: card.first);
However, when using card.last, in order to send via the 2nd sim slot like this:
sender.sendSms(message, simCard: card.last);
I always get this error.
E/flutter ( 6443): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 6443): PlatformException(#1, message state change error, null)
E/flutter ( 6443): #0 _rootHandleUncaughtError. (dart:async/zone.dart:1112:29)
E/flutter ( 6443): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 6443): #2 _startMicrotas
I am testing using Samsung Galaxy J7 Prime (SM-G610Y) with android version 6.0.1.
I'm writing an app to perform analytics on SMS history, and I'm unable to load contacts on my device (which is on the P beta, but I don't think that should be relevant to the issue).
When I try to run thread.findContact() it pops up the permission dialog which lets me choose to allow the app to read my contacts. That works fine. However, then it immediately throws.
Here's the stacktrace produced by the java method channel hook:
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): Failed to handle method call
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): java.lang.NegativeArraySizeException: -1
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at com.babariviere.sms.ContactPhotoQueryHandler.queryContactPhoto(ContactPhotoQuery.java:78)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at com.babariviere.sms.ContactPhotoQueryHandler.handle(ContactPhotoQuery.java:46)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at com.babariviere.sms.ContactPhotoQuery.onMethodCall(ContactPhotoQuery.java:133)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:136)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at android.app.ActivityThread.main(ActivityThread.java:6642)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.babariviere.com/queryContactPhoto(25064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Which can be found here https://github.com/babariviere/flutter_sms/blob/master/android/src/main/java/com/babariviere/sms/ContactPhotoQuery.java#L78
I would try to help fix it but unfortunately I am not very experienced with the Android side of Java.
Is this perhaps my issue? If you'd like, you can see how I'm setting up the threads here: https://github.com/ArcticZeroo/sms_analytics/blob/master/lib/api/sms_manager.dart#L78
Hey, I've been testing out this package with a pre-paid card and at some point the money ran out on it. I didn't know it at the time, I just started getting this error:
E/flutter ( 2677): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 2677): type 'PlatformException' is not a subtype of type 'String'
E/flutter ( 2677): #0 new SmsSender._private.<anonymous closure> (package:sms/sms.dart:311:71)
E/flutter ( 2677): #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter ( 2677): #2 _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:352:15)
E/flutter ( 2677): #3 _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:367:16)
E/flutter ( 2677): #4 _DelayedError.perform (dart:async/stream_impl.dart:589:14)
E/flutter ( 2677): #5 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter ( 2677): #6 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter ( 2677): #7 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 2677): #8 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Now that I know that, is there some way to catch this error so I can handle it? For eg. so that I can show a message with an error or keep the message in the queue to retry sending later.
I have upgrade dart sdk to 2.1.0 and now the plugin isn't working.
Good afternoon. I am using this plugin to send sms. On first access, after the permission requests, when it passes the "new SmsSender ()", it gives an error and closes the system. Follow the error below. Thanks
E/AndroidRuntime(26607): java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=5, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {br.com.emdurb.areaazulorientador/br.com.emdurb.areaazulorientador.MainActivity}: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(26607): at android.app.ActivityThread.deliverResults(Unknown Source:118) E/AndroidRuntime(26607): at android.app.ActivityThread.handleSendResult(Unknown Source:176) E/AndroidRuntime(26607): at android.app.ActivityThread.-wrap19(Unknown Source:0) E/AndroidRuntime(26607): at android.app.ActivityThread$H.handleMessage(Unknown Source:426) E/AndroidRuntime(26607): at android.os.Handler.dispatchMessage(Unknown Source:21) E/AndroidRuntime(26607): at android.os.Looper.loop(Unknown Source:139) E/AndroidRuntime(26607): at android.app.ActivityThread.main(Unknown Source:65) E/AndroidRuntime(26607): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(26607): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11) E/AndroidRuntime(26607): at com.android.internal.os.ZygoteInit.main(Unknown Source:335) E/AndroidRuntime(26607): Caused by: java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(26607): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174) E/AndroidRuntime(26607): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:194) E/AndroidRuntime(26607): at com.ethras.simplepermissions.SimplePermissionsPlugin.onRequestPermissionsResult(SimplePermissionsPlugin.java:172) E/AndroidRuntime(26607): at io.flutter.app.FlutterPluginRegistry.onRequestPermissionsResult(FlutterPluginRegistry.java:191) E/AndroidRuntime(26607): at io.flutter.app.FlutterActivityDelegate.onRequestPermissionsResult(FlutterActivityDelegate.java:125) E/AndroidRuntime(26607): at io.flutter.app.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:133) E/AndroidRuntime(26607): at android.app.Activity.dispatchRequestPermissionsResult(Unknown Source:21) E/AndroidRuntime(26607): at android.app.Activity.dispatchActivityResult(Unknown Source:37) E/AndroidRuntime(26607): at android.app.ActivityThread.deliverResults(Unknown Source:43) E/AndroidRuntime(26607): ... 9 more
Any sent message should have a function callback to be noticed on message sent/delivered.
hello when I install sms: "^0.0.9" with map_view: "^0.0.12" I have this issue.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
map_view: "^0.0.12"
sms: "^0.0.9"
FAILURE: Build failed with an exception.
Android dependency 'com.android.support:support-v4' has different version for the compile (25.2.0) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Finished with error: Gradle build failed: 1
C:\flutter\bin\flutter.bat --no-color doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] 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!
Process finished with exit code 0
I am trying how to determine if a message fails in sending, which can do so for various of reasons (no credit, bad signal and etc). However, I cannot seem to catch if the message fails when using:
SmsMessage message = new SmsMessage("address", "content");
message.onStateChanged.listen((state) {
if (state == SmsMessageState.Sent) {
print("SMS is sent!");
} else if (state == SmsMessageState.Delivered) {
print("SMS is delivered!");
} else {
print(state); <-- This will show "SmsMessageState.Sending"
}
});
sender.sendSms(message);
There seems to be no enum type for SmsMessageState for "failed":
enum SmsMessageState {
Sending,
Sent,
Delivered,
None,
}
Also, even if the message fails in sending, the SmsMessageState.Sent
still runs. I have not seen SmsMessageState.Delivered
being triggered, even if the message is successfully sent or not.
I think is a good idea to add the possibility to filtering/querying the SMS's collection of a specific contact (address)
Hi,
Getting following exception when trying to send message on android
E/flutter (27267): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (27267): type 'PlatformException' is not a subtype of type 'String'
E/flutter (27267): #0 new SmsSender._private. (package:sms/sms.dart:311:71)
E/flutter (27267): #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (27267): #2 _BufferingStreamSubscription._sendError.sendError (dart:async/stream_impl.dart:358:15)
E/flutter (27267): #3 _BufferingStreamSubscription._sendError (dart:async/stream_impl.dart:373:16)
E/flutter (27267): #4 _DelayedError.perform (dart:async/stream_impl.dart:595:14)
E/flutter (27267): #5 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:700:11)
E/flutter (27267): #6 _PendingEvents.schedule. (dart:async/stream_impl.dart:660:7)
E/flutter (27267): #7 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (27267): #8 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
SMS package version : 0.2.0
environment details
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.5.7, on Mac OS X 10.13.6 17G65, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Community Edition (version 2018.2.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected devices (3 available)
! Doctor found issues in 1 category.
When attempting to use the sms
library alongside simple_permissions
(https://pub.dartlang.org/packages/simple_permissions), the app crashes as soon as sms
initializes.
To reproduce, simply install simple_permissions
to the sms
example app and request a permission.
I think it's time for writing some documentation about the main functionalities of the package, and add it to the README.md file. I will start with it now.
Got this message from Textra. Not sure what it's referring to. Just putting it here for reference purposes.
refers you here.
I'm thinking about using it to save SMS messages that aren't received from another cell phone number, but read from a database
When trying to write a message to the phone's storage, received messages are written, but sent ones are not.
Sample code:
SmsDb smsDb = SmsDb();
await smsDb.insert(SmsMessage("1234567890", "On my way home,",
date: DateTime.fromMillisecondsSinceEpoch(1494552889918),
dateSent: DateTime.fromMillisecondsSinceEpoch(0),
kind: SmsMessageKind.Sent,
read: true));
await smsDb.insert(SmsMessage("1234567890", "Ok, see you soon!",
date: DateTime.fromMillisecondsSinceEpoch(1494552889918),
dateSent: DateTime.fromMillisecondsSinceEpoch(0),
kind: SmsMessageKind.Sent,
read: true));
var allSms = (await SmsQuery().getAllSms);
allSms.forEach((sms) => print(sms.toMap));
});
output:
{address: 1234567890, body: On my way home,, _id: 1, thread_id: 77, read: true, date: 1494552889918, dateSent: 0, kind: 1}
Total number of messages written: 2
Total number of messages read back: 1.
I want send sms from selected sim. any possiblity?
Support Dart 2 in pubspec.yaml.
The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about >upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.