Xamarin.ios 通过加载viewController并向其传递数据来处理远程通知

Xamarin.ios 通过加载viewController并向其传递数据来处理远程通知,xamarin.ios,xamarin.forms,Xamarin.ios,Xamarin.forms,我是Xamarin.iOS的新手,我试图找到我的问题以及如何处理通知,但我得到的只是一个警告示例 就像在whatsapp中,一旦你触摸到通知,就会打开一个带有数据的ViewController,我想做一些类似的事情。一旦收到带有文本的远程通知,我想在主ViewController中显示该文本。怎么做 我发现了一些类似的问题,但它们不是Swift就是Objective-c ,及 //when you app in background and user click your notific

我是Xamarin.iOS的新手,我试图找到我的问题以及如何处理通知,但我得到的只是一个警告示例

就像在whatsapp中,一旦你触摸到通知,就会打开一个带有数据的ViewController,我想做一些类似的事情。一旦收到带有文本的远程通知,我想在主ViewController中显示该文本。怎么做

我发现了一些类似的问题,但它们不是Swift就是Objective-c

,及

    //when you app in background and user click your notification
    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        Window = new UIWindow(UIScreen.MainScreen.Bounds);
        var userInfo = launchOptions.ValueForKey(UIApplication.LaunchOptionsRemoteNotificationKey) as NSDictionary;
        if (userInfo != null)
        {
            var message = userInfo.ValueForKey(new NSString("yourTextKey")) as NSString;
            var vc = new MessageViewController();
            vc.TextView.Text = message;
            Window.RootViewController = vc;

        }
        else
        {
            Window.RootViewController = new OtherRootViewController();
        }
        Window.MakeKeyAndVisible();
        return true;
    }

    //when you app in foreground
    public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
    {
        if (userInfo != null)
        {
            var message = userInfo.ValueForKey(new NSString("yourTextKey")) as NSString;
            var vc = new MessageViewController();
            vc.TextView.Text = message;
            Window.RootViewController.PresentViewController(vc, true, null);
        }
    }