简体   繁体   中英

How to navigate on specific page in Xamarin Forms iOS?

I am using Xamarin Forms and working with ANH notification. I am able to receive Notification from ANH. But the problem is when I am receiving notification and try to open it from notification area I want to redirect on a specific page of notification in iOS. I have used PendingIntent on Android, But for iOS I have no idea.

Also, I want to display a badge on the tab when an app is open and received notification. I am using CustomRenderer for iOS. My code is for TabRenderer is :

public class BottomTabbedPage : TabbedRenderer
{       
    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);
        TabBar.UnselectedItemTintColor = UIColor.FromRGB(208,208,208);
        TabBar.BackgroundColor = UIColor.White;
        TabBar.Items[1].BadgeValue = SettingClass.MenuNotificationCount == 0 ? null : SettingClass.MenuNotificationCount.ToString();
        TabBar.Items[2].BadgeValue = SettingClass.PromoNotificationCount == 0 ? null  : SettingClass.PromoNotificationCount.ToString();
    }
}

While App is starting badges will be displayed but when App is in background and notification is received count is increased but when the app is started badges are not updating. How can I solve this?

  • To navigate to a specific page you can use the below code in AppDelegate.cs when you receive or process the notification.

await App.Current.MainPage.Navigation.PushAsync(new specificPage());

  • To update the badge count when the app is open you need to capture the badge count when the notification is received and update it accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM