public NotificationModel ParceFromUNNotification(UNNotification notification)
        {
            NotificationModel notificationModel = new NotificationModel();

            if (notification.Request.Content.UserInfo.Keys.Count() != 0)
            {
                NSDictionary userInfo = notification.Request.Content.UserInfo;

                if (null != userInfo && userInfo.ContainsKey(new NSString("aps")))
                {
                    //Get the aps dictionary
                    NSDictionary aps   = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
                    NSDictionary alert = aps.ObjectForKey(new NSString("aps")) as NSDictionary;

                    notificationModel.AreaGUID        = (userInfo.ObjectForKey(new NSString("AreaGUID") as NSString))?.ToString();
                    notificationModel.NotificationUID = (userInfo.ObjectForKey(new NSString("NotificationUID") as NSString))?.ToString();
                    return(notificationModel);
                }

                if (userInfo.ContainsKey(new NSString("NotificationType")) && ((int.Parse((userInfo.ObjectForKey(new NSString("NotificationType") as NSString)).ToString())) == (int)NotificationType.LocalNotification))
                {
                    FeedActionModel actionModel = new FeedActionModel();

                    var action = userInfo.ObjectForKey(new NSString("Action")) as NSDictionary;

                    var actionParamDict = action.ObjectForKey(new NSString("ActionParamDict")) as NSDictionary;

                    actionModel.ActionScreen    = ((NSString)action["ActionScreen"]);
                    actionModel.ActionParamDict = new System.Collections.Generic.Dictionary <string, string>();
                    actionModel.WebRequestURL   = ((NSString)action["WebRequestUrl"]);

                    if (actionParamDict != null)
                    {
                        foreach (var item in actionParamDict)
                        {
                            actionModel.ActionParamDict.Add((NSString)item.Key, (NSString)item.Value);
                        }
                    }
                    notificationModel.Message          = notification.Request.Content.Body; // (alert[new NSString("NotificationUID")] as NSString)?.ToString();
                    notificationModel.NotificationType = NotificationType.LocalNotification;
                    notificationModel.Action           = actionModel;
                    notificationModel.AreaGUID         = (userInfo.ObjectForKey(new NSString("AreaGUID") as NSString))?.ToString();
                    //notificationModel = JsonConvert.DeserializeObject<NotificationModel>(userInfo.ToString());
                    return(notificationModel);
                }
            }
            return(notificationModel);
        }
        public void HandleActionAsync(FeedActionModel model, string actionType = null, string AreaGUID = null)
        {
            if (model == null)
            {
                /*
                 * UIAlertView alert = new UIAlertView()
                 * {
                 *  Title = "Action error",
                 *  Message = "Action data empty"
                 * };
                 * alert.AddButton("OK");
                 * alert.Show();
                 */
                return;
            }
            UIStoryboard storyboard         = UIStoryboard.FromName("Main", null);
            var          rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController as UINavigationController;

            if ((model.ActionScreen == "CHALLENGE" || actionType == "REFERRAL_ACCEPTED" || actionType == "ITB_COMPLETE" || actionType == "CTAC") && model.ActionScreen != "DIALOG")
            {
                OpenChallengeDetailsScreenWithURL(model.ActionParamDict["ChallengeDetailURL"]);
                return;
            }
            if (model.ActionScreen == "REWARD")
            {
                SL.Manager.GetRewardByUrl(model.ActionParamDict["RewardDetailURL"], GetRewardByUrlComplete);

                return;
            }
            if (model.ActionScreen == "REWARDLIST")
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.REWARDS);
            }
            if (model.ActionScreen == "CHALLENGELIST")///////////////////
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.CHALLENGES);
            }
            if (model.ActionScreen == "FEED")
            {
                string feedUrl = string.Empty;
                model.ActionParamDict.TryGetValue("FeedURL", out feedUrl);

                LoadFeedByUrl(feedUrl);
                //NavigateByAction("Main", "MainNav1", ENavigationTabs.FEED);
            }
            if (model.ActionScreen == "WEB")
            {
                string url    = string.Empty;
                bool   gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url);
                if (gotUrl == false)
                {
                    url = model.WebRequestURL;
                }
                if (url == string.Empty)
                {
                    //alert no url to open
                    //return;
                }
                UIApplication.SharedApplication.OpenUrl(new NSUrl(url));
            }
            if (model.ActionScreen == "SETTINGS")
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.MORE);
            }
            if (model.ActionScreen == "SHARE")
            {
                if (!model.ActionParamDict.ContainsKey("ChallengeDetailURL"))
                {
                    return;
                }

                OpenChallengeDetailsScreenWithURL(model.ActionParamDict["ChallengeDetailURL"]);
            }
            if (model.ActionScreen == "SwitchArea")
            {
                SwitchAreaIfNeeded(AreaGUID);
            }
            if (model.ActionScreen == "INVITE")
            {
                SL.Manager.RefreshShareTemplate(model.ActionParamDict["ShareTemplateURL"], SendInviteMessage);
            }
            if (model.ActionScreen == "DIALOG")///////////////////
            {
                var dialogStyle = model.ActionParamDict["DialogStyle"];
                _dialogSubmisionUrl = model.ActionParamDict["SubmissionURL"];

                var message = model.ActionParamDict["Caption"];
                if (dialogStyle != string.Empty)
                {
                    if (dialogStyle == "NONE")
                    {
                    }
                    if (dialogStyle == "ENTRY")
                    {
                        var alert = new UIAlertView("", message, this as IUIAlertViewDelegate, "Cancel", null);
                        alert.AddButton("Ok");
                        alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                        var textField = alert.GetTextField(0);
                        alert.Show();
                    }
                }
            }

            if (model.ActionScreen == "IWEB" && actionType == "CTAIW")
            {
                string url    = string.Empty;
                bool   gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url);
                url = model.ActionParamDict["WebRequestURL"];
                if (gotUrl == false)
                {
                    //url = model.WebRequestURL;
                }
                if (url == string.Empty)
                {
                    //alert no url to open
                    //return;
                }
                GenericWebViewController webViewController = new GenericWebViewController();
                webViewController.Url = url;

                UIViewController parentController = Platform.TopViewController;
                parentController.PresentViewController(webViewController, false, null);

                return;
            }

            if (model.ActionScreen == "IWEB")
            {
                string url    = string.Empty;
                bool   gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url);
                if (gotUrl == false)
                {
                    url = model.WebRequestURL;
                }
                if (url == string.Empty)
                {
                    //alert no url to open
                    //return;
                }
                UIApplication.SharedApplication.OpenUrl(new NSUrl(url));
            }

            if (model.ActionScreen == "SCORE")
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS);
            }
            if (model.ActionScreen == "FRIENDLIST")
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS);
            }
        }
        public async Task HandleActionAsync(IMvxNavigationService navigationService, IAlertService alertService, IMvxMessenger messenger, FeedActionModel model, string actionType = null, string AreaGUID = null)
        {
            _navigationService         = navigationService;
            _alertService              = alertService;
            _messenger                 = messenger;
            _platformNavigationService = Mvx.Resolve <IPlatformNavigationService>();
            if (model == null)
            {
                return;
            }
            if ((model.ActionScreen == ActionTypeConstants.ChallengeActionType || actionType == ActionTypeConstants.ReferralAcceptedActionType ||
                 actionType == ActionTypeConstants.ItbCompletedActionType || actionType == ActionTypeConstants.CtacActionType) && model.ActionScreen != ActionTypeConstants.DialogActionType)
            {
                OpenChallengeDetailsScreenWithURL(model.ActionParamDict[ActionTypeConstants.ChallengeDetailURLActionParamDict]);
                return;
            }
            if (model.ActionScreen == ActionTypeConstants.RewardActionType)
            {
                await SL.Manager.GetRewardByUrl(model.ActionParamDict[ActionTypeConstants.RewardDetailURLActionParamDict], GetRewardByUrlComplete);

                return;
            }
            if (model.ActionScreen == ActionTypeConstants.RewardListActionType)
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.REWARDS);
            }
            if (model.ActionScreen == ActionTypeConstants.ChallengeListActionType)
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.CHALLENGES);
            }
            if (model.ActionScreen == ActionTypeConstants.FeedActionType)
            {
                string feedUrl = string.Empty;
                model.ActionParamDict.TryGetValue(ActionTypeConstants.FeedURLActionParamDict, out feedUrl);
                if ((actionType == ActionTypeConstants.AggChalcompActionType) || (actionType == ActionTypeConstants.AggCommitActionType))
                {
                    await LoadFeedByUrl(feedUrl);
                }
                else
                {
                    await LoadFeedByUrl(feedUrl, true);
                }
            }
            if (model.ActionScreen == ActionTypeConstants.WebActionType)
            {
                string url    = string.Empty;
                bool   gotUrl = model.ActionParamDict.TryGetValue(ActionTypeConstants.WebRequestURLActionParamDict, out url);
                if (gotUrl == false)
                {
                    url = model.WebRequestURL;
                }
                if (url == string.Empty)
                {
                    _alertService.ShowToast("There isn't url to open");
                }
                _platformNavigationService.NavigateToUrl(url);
            }
            if (model.ActionScreen == ActionTypeConstants.SettingsActionType)
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.MORE);
            }
            if (model.ActionScreen == ActionTypeConstants.ShareActionType)
            {
                if (!model.ActionParamDict.ContainsKey(ActionTypeConstants.ChallengeDetailURLActionParamDict))
                {
                    return;
                }

                OpenChallengeDetailsScreenWithURL(model.ActionParamDict[ActionTypeConstants.ChallengeDetailURLActionParamDict]);
            }
            if (model.ActionScreen == ActionTypeConstants.SwitchAreaActionType)
            {
                await SwitchAreaIfNeeded(AreaGUID);
            }
            if (model.ActionScreen == ActionTypeConstants.InviteActionType)
            {
                await SL.Manager.RefreshShareTemplate(model.ActionParamDict[ActionTypeConstants.ShareTemplateURLActionParamDict], SendInviteMessage);
            }
            if (model.ActionScreen == ActionTypeConstants.DialogActionType)
            {
                var dialogStyle = model.ActionParamDict[ActionTypeConstants.DialogStyleActionParamDict];
                _dialogSubmisionUrl = model.ActionParamDict[ActionTypeConstants.SubmissionURLActionParamDict];

                var message = model.ActionParamDict[ActionTypeConstants.CaptionActionParamDict];
                if (dialogStyle != string.Empty)
                {
                    if (dialogStyle == ActionTypeConstants.NoneDialogStyle)
                    {
                    }
                    if (dialogStyle == ActionTypeConstants.EntryDialogStyle)
                    {
                        var result = await _alertService.ShowAlertWithInput("", message, string.Empty, "Ok", "Cancel");

                        Dismissed(result);
                    }
                }
            }

            if (model.ActionScreen == ActionTypeConstants.IWebActionType && actionType == ActionTypeConstants.CtaiwActionType)
            {
                string actionUrl = string.Empty;
                bool   gotUrl    = model.ActionParamDict.TryGetValue(ActionTypeConstants.WebRequestURLActionParamDict, out actionUrl);
                if (string.IsNullOrEmpty(actionUrl))
                {
                    var firstUrl = model.ActionParamDict.Values.Count > 0 ? model.ActionParamDict.Values.FirstOrDefault() : string.Empty;
                    actionUrl = model.ActionParamDict[ActionTypeConstants.WebRequestURLActionParamDict] ?? firstUrl;
                }
                if (gotUrl == false)
                {
                    //url = model.WebRequestURL;
                }
                if (string.IsNullOrEmpty(actionUrl))
                {
                    _alertService.ShowToast("There isn't url to open");
                    return;
                }

                //actionUrl = "https://goo.gl/?link=" + actionUrl;
                await _navigationService.Navigate <WebViewModel>();

                _messenger.Publish <MessangerWebModel>(new MessangerWebModel(this, actionUrl, true));
                return;
            }

            if (model.ActionScreen == ActionTypeConstants.IWebActionType)
            {
                string url    = string.Empty;
                bool   gotUrl = model.ActionParamDict.TryGetValue(ActionTypeConstants.WebRequestURLActionParamDict, out url);
                if (gotUrl == false)
                {
                    url = model.WebRequestURL;
                }
                if (url == string.Empty)
                {
                    _alertService.ShowToast("There isn't url to open");
                }
                _platformNavigationService.NavigateToUrl(url);
            }
            if (model.ActionScreen == ActionTypeConstants.ScoreActionType)
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS);
            }
            if (model.ActionScreen == ActionTypeConstants.FriendListActionType)
            {
                NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS);
            }
        }