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

IOS 13 doesn't play a notification sound when the notification is received. #348

Closed
cjsharp01 opened this issue Jul 29, 2020 · 1 comment

Comments

@cjsharp01
Copy link

cjsharp01 commented Jul 29, 2020

Bug Information

Version Number of Plugin: 3.3.10
Device Tested On: iphone X, OS: 13.4.1
Simulator Tested On: N/A (simulators don't receive notifications)
Version of VS: VS for Mac Community, 8.6.6 (build 11)
Version of Xamarin: Xamarin.IOS 13.18.2.1, Xamarin.Forms v4.6.0.847
Versions of other things you are using:

Steps to reproduce the Behavior

  • Register tags/topic on the phone.
  • Send out notification via firebase for specific tag.
  • iPhone receives notification

Expected Behavior

A default sound should occur.

Actual Behavior

The notification appears on the list of notifications but no sound is played.

Code snippet

AppDelegate.cs:

        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
 bool fbaseStarted = false;
            try
            {
                // This method does all the UNUserNotificationCenter.Current.RequestAuthorization() code so we don't have to.
                FirebasePushNotificationManager.Initialize(options, true);
                fbaseStarted = true;
            }
            catch
            { }
            LoadApplication(new App());
            if (!fbaseStarted)
            {
                try

                {
                    FirebasePushNotificationManager.Initialize(options, true);
                }
                catch { }
            }

            // Set the default notification type and sound - not sure if this works at the moment
            FirebasePushNotificationManager.CurrentNotificationPresentationOption = UNNotificationPresentationOptions.Badge | UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound;
     }

I subscribe a list of tags (please note that I unsubscribe because the first time the code runs it fails silently if the notifications aren't approved - resulting in the model thinking the notifications was subscribed when it wasn't):

               CrossFirebasePushNotification.Current.UnsubscribeAll();
               CrossFirebasePushNotification.Current.Subscribe(Constants.NotificationTagsArray);

Screenshots

@cjsharp01
Copy link
Author

The issue actually lies with the sending of the notifications nothing to do with the Xamarin App. The issue resided in the services that sends the notifications to firebase (to then be sent out to the phones).

In the service we were sending a FirebaseNet.Messaging.Message() to the phones:

  Message FireBasemessage = new Message()
                        {
                            To = "/topics/" + PushNote.Tag,
                            TimeToLive = 86400,
                            Priority = MessagePriority.high,
                            ContentAvailable = true,

                            Notification = new AndroidNotification()
                            {
                                
                                Tag = "/topics/" + PushNote.Tag,
                                Body = enhancedMessage,
                                Title = xtitle,
                            }
                            ,
                            Data = new Dictionary<string, string>
                                {
                                    { "param", PushNote.Tag },
                                    { "text",  enhancedMessage} 
                                }
                        };

In the AndroidNotification() object required Sound = "default" to be added for it to work. Please note that this works for both Android and IOS notifications despite the fact it is an AndroidNotification object.

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

1 participant