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

Notication with Alarm Sound is not working #877

Closed
DevDaring opened this issue Oct 29, 2020 · 1 comment
Closed

Notication with Alarm Sound is not working #877

DevDaring opened this issue Oct 29, 2020 · 1 comment

Comments

@DevDaring
Copy link

DevDaring commented Oct 29, 2020

I have used this method from example code.
Future _showSoundUriNotification()
Here is my code
static const MethodChannel platform = MethodChannel('your channel name'); Future<void> showNotificationWithAlarmSound() async { /// this calls a method over a platform channel implemented within the /// example app to return the Uri for the default alarm sound and uses /// as the notification sound var iOSPlatformChannelSpecifics = new IOSNotificationDetails(); final String alarmUri = await platform.invokeMethod('getAlarmUri'); final UriAndroidNotificationSound uriSound = //UriAndroidNotificationSound(AndroidSounds.alarm.toString()); UriAndroidNotificationSound(alarmUri); final AndroidNotificationDetails androidPlatformChannelSpecifics = AndroidNotificationDetails( 'uri channel id', 'your channel name', 'your channel description', sound: uriSound, styleInformation: const DefaultStyleInformation(true, true)); final NotificationDetails platformChannelSpecifics = NotificationDetails(androidPlatformChannelSpecifics,iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( 0, 'uri sound title', 'uri sound body', platformChannelSpecifics); }

While I am running the code I am getting this error
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAlarmUri on channel your channel name)

Here is full trace

E/flutter (13856): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
E/flutter (13856):
E/flutter (13856): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (13856): #2 NotificationManager.showNotificationWithAlarmSound (package:combine/add_alarm.dart:59:44)
E/flutter (13856): #3 _AddAlarmState._ringAlarm (package:combine/add_alarm.dart:329:7)
E/flutter (13856): #4 _AddAlarmState.build.. (package:combine/add_alarm.dart:280:39)
E/flutter (13856): #5 _Callback.init. (package:combine/alarm_manager.dart:443:13)
E/flutter (13856): #6 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (13856): #7 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (13856): #8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (13856): #9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter (13856): #10 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter (13856): #11 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter (13856): #12 _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter (13856): #13 _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter (13856): #14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (13856):

I have used other notification methods that worked fine for me.

@MaikuB
Copy link
Owner

MaikuB commented Oct 31, 2020

As mentioned in the comments for the example app itself, you can't just copy the Dart code and expect it to work. The code related await platform.invokeMethod('getAlarmUri') makes use of platform channels and is specific to the app itself. It isn't code that is implemented by the plugin. I explicitly mention this in the comments as well

/// this calls a method over a platform channel implemented within the
/// example app to return the Uri for the default alarm sound and uses
/// as the notification sound

This is a gap in your app that you will need to address and not an issue with the plugin so will be closing. Please take care to look at the comments and code involved more closely in the future and read about platform channels

@MaikuB MaikuB closed this as completed Oct 31, 2020
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

2 participants