简体   繁体   English

如何在Xamarin Forms iOS中的特定页面上导航?

[英]How to navigate on specific page in Xamarin Forms iOS?

I am using Xamarin Forms and working with ANH notification. 我正在使用Xamarin Forms并正在使用ANH通知。 I am able to receive Notification from ANH. 我可以从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. 但是问题是当我收到通知并尝试从通知区域打开时,我想在iOS的通知的特定页面上进行重定向。 I have used PendingIntent on Android, But for iOS I have no idea. 我在Android上使用了PendingIntent ,但对于iOS我不知道。

Also, I want to display a badge on the tab when an app is open and received notification. 另外,我想在应用打开并收到通知时在选项卡上显示徽章。 I am using CustomRenderer for iOS. 我正在使用iOS的CustomRenderer My code is for TabRenderer is : 我的TabRenderer代码是:

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. 当App启动时,将显示徽章,但是当App在后台运行且收到通知时,计数会增加,但在App启动时,徽章不会更新。 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. 要导航到特定页面,您可以在收到或处理通知时在AppDelegate.cs中使用以下代码。

await App.Current.MainPage.Navigation.PushAsync(new specificPage()); 等待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. 要在打开应用程序时更新徽章计数,您需要在收到通知时捕获徽章计数并进行相应的更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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