thudugala / Plugin.LocalNotification

The local notification plugin provides a way to show local notifications from .Net MAUI and Xamarin Forms apps .
MIT License
425 stars 68 forks source link

No sound on IOS #331

Closed michaelconnolly1 closed 1 year ago

michaelconnolly1 commented 1 year ago

I am not getting any sound on iOS devices, only Android. I have tried downloading various versions of the sample and ran it on 2 iPhones, an iPad and an iPad mini and none of them play any sound when the notification occurs. Any suggestions (the settings on all the devices seem fine). Devices are on iOS 14.6 with the exception of the iPad mini on 12.5.

thudugala commented 1 year ago

Please follow https://github.com/thudugala/Plugin.LocalNotification/wiki/Notification-with-a-Sound-File

michaelconnolly1 commented 1 year ago

Yes, I have followed the instructions; as I mentioned I have tried the sample projects and I'm not getting any sounds on iOS although I do for other apps. Does the sound file have to have a specific bundle type?

thudugala commented 1 year ago

@michaelconnolly1 https://github.com/dotnet/maui/issues/8612

thudugala commented 1 year ago

@michaelconnolly1

Can you please try adding the sound file to iOS resources folder?

image

Also, make sure to Add BundleResource link in csproj

  <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
    <BundleResource Include="Platforms\iOS\Resources\good_things_happen.aiff" Link="Resources\good_things_happen.aiff" />
  </ItemGroup>
peter-bozovic commented 1 year ago

I had similar issue, and it turned out I didn't include the sound with my authorisation request ...

So, after changing it and included UNAuthorizationOptions.Sound it worked : UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound, (approved, err) => { });

You can also check in the system settings of your application if the Notifications have Banner/Sound options and if the sound is not turned off there ...