0

我正在使用Azure通知中心推送通知。當後臺應用程序和接收推送通知點擊應用程序崩潰時

我想從AppDelegate開始我的應用程序,其中通知是點擊。

這是場景,我如何打開我的應用程序。

AppDelegate.cs文件

public class AppDelegate : UIApplicationDelegate 
    { 
     // class-level declarations 
     private SBNotificationHub Hub { get; set; } 

     public bool appIsStarting = false; 

     public SlideoutNavigationController Menu { get; private set; } 


     public override UIWindow Window 
     { 
      get; 
      set; 
     } 

     public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) 
     { 
      if (launchOptions != null) 
      { 
       // check for a remote notification 
       if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) 
       { 

        NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; 
        if (remoteNotification != null) 
        { 
         Window = new UIWindow(UIScreen.MainScreen.Bounds); 
         Menu = new SlideoutNavigationController(); 

         var storyboard = UIStoryboard.FromName("Main", null); 
         var webController = storyboard.InstantiateViewController("DashBoardViewController") as DashBoardViewController; 

         Menu.MainViewController = new MainNavigationController(webController, Menu); 
         Menu.MenuViewController = new MenuNavigationController(new DummyControllerLeft(), Menu) { NavigationBarHidden = false }; 

         Window.RootViewController = Menu; 
         Window.MakeKeyAndVisible(); 
        } 
       } 
       ReceivedRemoteNotification(application, launchOptions); 

      } 
      else 
      { 

       UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false); 
       UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; 
      } 

      UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate(); 

      return true; 
     } 
} 

UserNotificationCenterDelegate.cs文件

class UserNotificationCenterDelegate : UNUserNotificationCenterDelegate 
    { 

     public SlideoutNavigationController Menu { get; private set; } 



     #region Constructors 
     public UserNotificationCenterDelegate() 
     { 
     } 
     #endregion 

     #region Override Methods 
     public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler) 
     { 
      // Do something with the notification 
      Console.WriteLine("Active Notification: {0}", notification); 


      // Tell system to display the notification anyway or use 
      // `None` to say we have handled the display locally. 
      completionHandler(UNNotificationPresentationOptions.Alert); 
     } 

     public override void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler) 
     { 
      base.DidReceiveNotificationResponse(center, response, completionHandler); 
     } 

     #endregion 
    } 

我已經嘗試了所有可能的方案,我發現在谷歌和因此和其他的網站,但沒有什麼工作爲了我。

我花了4天,但沒有取得成功。

任何幫助將被讚賞。

+0

你把日誌也放在斷點....? –

+0

當您嘗試打開時,您可以分享什麼是崩潰日誌。 –

+0

@GouravJoshi我正在測試釋放模式,所以斷點不起作用。 – Ironman

回答

0

您是否在設備日誌中檢查過窗口 - >設備 - >查看設備日誌?必須記錄崩潰。

+0

使用Crashlytics,SplunkMint等任何框架。它確實有助於在旅途中記錄崩潰。 – 2017-07-25 08:26:05

+0

我在發佈模式下部署,因此沒有可用的選項。 – Ironman

+0

僅供參考,你不想收到實時應用用戶的崩潰報告嗎? – 2017-07-25 08:29:42

相關問題