我正在使用Azure Notification Hub进行推送通知。
我想从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)
您是否已检入DeviceLogs 窗口 - &gt;设备 - &gt;查看设备日志?必须记录崩溃。