RobertHedgate / MauiAppPush

Starter code on how to make push from azure to work
1 stars 1 forks source link

Maui -Azure notification hub iOS not all events fire for me #1

Open developer9969 opened 2 months ago

developer9969 commented 2 months ago

Hi there,

thank you for putting together this starting point app - really really appreciate it. I have written an implementation (MAUI) for iOS

I can

Does not work for me

  1. WillPresentNotification does not fire
  2. I cannot receive notification in the foreground (app is displaying) I have "I think" all the code in place .. obviously not -
  3. Tapping on a notification
  4. Notifications receival on phisycal device only works when deployed - Cannot get it working in debug - I must have something wrong set up ..

Do you have any of the above issues?

Huge thanks for you time

RobertHedgate commented 2 months ago
  1. This line in FinishedLaunching UNUserNotificationCenter.Current.Delegate = new UserNotificaitonCenterDelegate(); sets the UNUserNotificationCenterDelegate. Thats all I do to get WillPresentNotification to work
  2. If 1 doesn´t work this won´t either. My code has an alert if push comes when app is in foreground.
  3. By tapping you mean open app or get some info? I only use tapping a notification to open the app, have not tries deep links. Have little use for it in my app.
  4. Debug on a device works sometimes at best. Not even sure a have debugged push on a device :) It works on simulator.
RobertHedgate commented 2 months ago

I realazied that i forgot to add these lines to info.plist. Might help

UIBackgroundModes remote-notification fetch
developer9969 commented 2 months ago

Hi there I used that line too

public partial class PushNotificationService : NSObject, IPushNotificationService, IUNUserNotificationCenterDelegate
{
public async Task<RegistrationResponse> RegisterAsync(CancellationToken cancelToken = default)
{                    
       UNUserNotificationCenter.Current.Delegate = this as IUNUserNotificationCenterDelegate;

//   etc... omitted irrelavant code for brevity.
 }   
}

In the FinishedLaunching I call the RegisterAsync ..   the difference from your sample is that I use an interface rather than the concrete class and in the info.plist I have

<key>UIBackgroundModes</key>
<array>
    <string>remote-notification</string>
</array>

I will try with concrete implementation and see if makes a difference,

When tapping - the even should fire (and then I can go to whatever page I need to go )

I guess to get it working would be a start... Debugging it too would be nice.

if you have any more info - please share , documentation is very patchy

many thanks