1

I have implemented the push notifications for Android and IOS in Xamarin but notifications are only received while phone is locked and app is in background. Is there any way to receive notification while App is running or phone is not locked? I have implemented push notification for the first time in Xamarin so having hard time.

Zeeshan shaikh
  • 341
  • 1
  • 5
  • 24

2 Answers2

1

Is there any way to receive notification while App is running or phone is not locked?

What do you mean by not receive notification ?

  • No notification displays at the top of the screen

Or

  • OnMessageReceived method does not trigger

For Azure Notificaiton Hubs , notification only displays when the app is in background and closed .

When the app is running in foreground , notification would not display at top of the screen , but the OnMessageReceived would be triggered as normal .

ColeX
  • 14,062
  • 5
  • 43
  • 240
  • I mean to say when user is using the application or app is running in foreground, how do we achieve if it is not possible using Notification hub? – Zeeshan shaikh Sep 20 '21 at 12:21
  • We can send local notification in `OnMessageReceived ` method ,refer to https://stackoverflow.com/questions/69244853/azure-push-notification-not-closing-after-click-when-app-is-open/69248664#69248664 – ColeX Sep 21 '21 at 03:24
0

If you follow the Microsoft documentation you should be able to recieve the notifications in any moment. Normally notifications would work in any moment, not just when the phone is locked and the app is in background. It will depend on the way that you implemented the feature

Juan Sturla
  • 1,254
  • 1
  • 4
  • 18
  • The link you have shared is the local notification, I have implemented using https://learn.microsoft.com/en-us/azure/developer/mobile-apps/notification-hubs-backend-service-xamarin-forms and getting notifications only when phone is locked. – Zeeshan shaikh Sep 17 '21 at 18:39