Open stesvis opened 5 years ago
in iOS add this to your AppDelegate.cs
public async override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
{
}
Hi guys, is there any chance to have this implemented on Android? I need to open app when user clicks on notification and display an alert controller. Thanks
on Android you can add
protected override void OnNewIntent(Intent intent)
{
}
and if you are passing some data with your notification you can do something like
On Android
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
var fromid = intent.GetStringExtra("fromid");
if (fromid != null && fromid != "")
{
MessagingCenter.Send<object, string>(this, "PushToChat", intent.GetStringExtra("fromid"));
}
System.Diagnostics.Debug.WriteLine("Exta fromid: "+intent.GetStringExtra("fromid"));
System.Diagnostics.Debug.WriteLine("Exta Time: " + intent.GetStringExtra("datetime"));
System.Diagnostics.Debug.WriteLine("Exta message: " + intent.GetStringExtra("message"));
}
On IOS
[Export("application:didReceiveLocalNotification:")]
public void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
{
var userdata = notification.UserInfo;
var fromid = userdata.ValueForKey(new NSString("fromid")).ToString();
if (fromid != null && fromid != "")
{
MessagingCenter.Send<object, string>(this, "PushToChat", userdata.ValueForKey(new NSString("fromid")).ToString());
}
}
Is there a way to handle the notification click event? If not....
Feature Request
In 99.9% of the cases, when a local notification is fired we need to do something. It would be hugely helpful to add a LocalNotificationReceived event handler.