【问题标题】:How to show badge count in Xamarin iOS when application in background在后台应用程序时如何在 Xamarin iOS 中显示徽章计数
【发布时间】:2018-10-04 22:28:36
【问题描述】:

任何人都可以告诉我在后台应用程序时在 Xamarin iOS 中显示徽章计数的任何想法

实际上在后台通知到来时,Xamarin iOS 中没有任何方法触发。

【问题讨论】:

  • 您不能只向他人索取代码,您需要展示您的进度以及您尝试实现的目标。
  • 为什么?你是来评判活动的,如果我谈论我的问题,如果你知道然后需要回复,堆栈溢出将不会在获得信用后给予 CEO 的位置​​。
  • 后台申请时无法通过代码控制徽章编号,但可以在推送通知的payload中发送徽章编号,参考this answer
  • @ColeXia-MSFT 同意但需要任何其他想法而不是上面的想法?
  • @ShashikantYadav,您是否发现当应用程序处于后台并且在 iOS 中收到通知时会触发任何方法?

标签: xamarin xamarin.forms xamarin.ios


【解决方案1】:
public class UserNotificationCenterDelegate : UNUserNotificationCenterDelegate
{
    #region Constructors
    public UserNotificationCenterDelegate()
    {
    }
    #endregion

    #region Override Methods
    public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
    {
           /// here we can add badge 

    }
}

*****************
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
    {

      UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
       ----------
       ------------

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-11
    • 2012-12-25
    • 2017-10-06
    • 1970-01-01
    相关资源
    最近更新 更多