Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot send SMS while in background #72

Open
GokulakrishnanV opened this issue Aug 18, 2022 · 6 comments
Open

cannot send SMS while in background #72

GokulakrishnanV opened this issue Aug 18, 2022 · 6 comments

Comments

@GokulakrishnanV
Copy link

This is my code:
print("Handling a background message: ${message.messageId}"); print('Message data: ${message.data}'); String mobile = message.data['mobile_numbers']; FCM.mobile = mobile.split(','); FCM.message = message.data['message']; await sendSMS(message: FCM.message, recipients: FCM.mobile, sendDirect: true);

and the error is:
E/MethodChannel#flutter_sms(12626): Failed to handle method call
E/MethodChannel#flutter_sms(12626): java.lang.NullPointerException
E/MethodChannel#flutter_sms(12626): at com.example.flutter_sms.FlutterSmsPlugin.canSendSMS(FlutterSmsPlugin.kt:95)
E/MethodChannel#flutter_sms(12626): at com.example.flutter_sms.FlutterSmsPlugin.onMethodCall(FlutterSmsPlugin.kt:76)
E/MethodChannel#flutter_sms(12626): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#flutter_sms(12626): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#flutter_sms(12626): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter_sms(12626): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#flutter_sms(12626): at android.os.Handler.handleCallback(Handler.java:883)
E/MethodChannel#flutter_sms(12626): at android.os.Handler.dispatchMessage(Handler.java:100)
E/MethodChannel#flutter_sms(12626): at android.os.Looper.loop(Looper.java:224)
E/MethodChannel#flutter_sms(12626): at android.app.ActivityThread.main(ActivityThread.java:7562)
E/MethodChannel#flutter_sms(12626): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_sms(12626): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/MethodChannel#flutter_sms(12626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I/flutter (12626): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (12626): PlatformException(error, null, null, java.lang.NullPointerException
I/flutter (12626): at com.example.flutter_sms.FlutterSmsPlugin.canSendSMS(FlutterSmsPlugin.kt:95)
I/flutter (12626): at com.example.flutter_sms.FlutterSmsPlugin.onMethodCall(FlutterSmsPlugin.kt:76)
I/flutter (12626): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
I/flutter (12626): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
I/flutter (12626): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
I/flutter (12626): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
I/flutter (12626): at android.os.Handler.handleCallback(Handler.java:883)
I/flutter (12626): at android.os.Handler.dispatchMessage(Handler.java:100)
I/flutter (12626): at android.os.Looper.loop(Looper.java:224)
I/flutter (12626): at android.app.ActivityThread.main(ActivityThread.java:7562)
I/flutter (12626): at java.lang.reflect.Method.invoke(Native Method)
I/flutter (12626): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.j

@cherlow
Copy link

cherlow commented Dec 20, 2022

Did you figure this out? Am having the same problem.

@GokulakrishnanV
Copy link
Author

Yes, It was a permission issue. Resolved.

@gonChronoPer
Copy link

Am having the same problem. What permission should I add or what should I change in the permissions?

@gonChronoPer
Copy link

E/MethodChannel#flutter_sms( 9619): Failed to handle method call
E/MethodChannel#flutter_sms( 9619): java.lang.NullPointerException
E/MethodChannel#flutter_sms( 9619): at com.example.flutter_sms.FlutterSmsPlugin.canSendSMS(FlutterSmsPlugin.kt:95)
E/MethodChannel#flutter_sms( 9619): at com.example.flutter_sms.FlutterSmsPlugin.onMethodCall(FlutterSmsPlugin.kt:76)
E/MethodChannel#flutter_sms( 9619): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#flutter_sms( 9619): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#flutter_sms( 9619): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#flutter_sms( 9619): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
E/MethodChannel#flutter_sms( 9619): at android.os.Handler.handleCallback(Handler.java:751)
E/MethodChannel#flutter_sms( 9619): at android.os.Handler.dispatchMessage(Handler.java:95)
E/MethodChannel#flutter_sms( 9619): at android.os.Looper.loop(Looper.java:154)
E/MethodChannel#flutter_sms( 9619): at android.app.ActivityThread.main(ActivityThread.java:6816)
E/MethodChannel#flutter_sms( 9619): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_sms( 9619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
E/MethodChannel#flutter_sms( 9619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
I/flutter ( 9619): PlatformException(error, null, null, java.lang.NullPointerException
I/flutter ( 9619): at com.example.flutter_sms.FlutterSmsPlugin.canSendSMS(FlutterSmsPlugin.kt:95)
I/flutter ( 9619): at com.example.flutter_sms.FlutterSmsPlugin.onMethodCall(FlutterSmsPlugin.kt:76)
I/flutter ( 9619): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
I/flutter ( 9619): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
I/flutter ( 9619): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
I/flutter ( 9619): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)

@gom59
Copy link

gom59 commented Mar 2, 2023

Can you share what the permission issue was? Thanks.

@Lyazz
Copy link

Lyazz commented Mar 19, 2023

What's the permission to add ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants