Example #1
0
        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            ParsePush.HandlePush(userInfo);

            NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;

            string alert = "";

            if (aps.ContainsKey(new NSString("alert")))
            {
                alert = (aps [new NSString("alert")] as NSString).ToString();
            }

            alert = alert.Replace("Nuovo evento creato: ", "");
            var detail = new UIEventDetail(true);

            detail.key   = alert;
            detail.Title = "Eventi";
            this.navigationController.PushViewController(detail, true);


            application.ApplicationIconBadgeNumber = 0;

            application.CancelAllLocalNotifications(); //.ca
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            timerstarted = false;

            this.Title = "iPortogruaro";
            int iniheight = 110;
            int iniweight = 320;

            if (UserInterfaceIdiomIsPhone)
            {
                switch (InterfaceOrientation)
                {
                case UIInterfaceOrientation.LandscapeLeft:
                case UIInterfaceOrientation.LandscapeRight:
                    if (IsTall)
                    {
                        iniheight = 568;
                        iniweight = 100;
                    }
                    else
                    {
                        iniheight = 480;
                        iniweight = 150;
                    }
                    break;

                default:
                    iniheight = 110;
                    iniweight = 320;
                    break;
                }
            }
            else
            {
                switch (InterfaceOrientation)
                {
                case UIInterfaceOrientation.LandscapeLeft:
                case UIInterfaceOrientation.LandscapeRight:
                    iniweight = 1024;
                    //iniheight = 240;
                    iniheight = 290;
                    break;

                default:
                    iniweight = 1024;
                    iniheight = 290;
                    break;
                }
            }
            setScroll(iniweight, iniheight);
            loadMainCategory();
            loadMap();

            if (firstTime > 1 && !gotoEvent)
            {
                int clicked = -1;
                var x       = new UIAlertView("iPortogruaro", "Si conferma l'aggiornamento dal server? L'operazione potrebbe durare alcuni secondi.", null, "Annullare", "Aggiornare");
                x.Show();
                bool done = false;
                x.Clicked += (sender, buttonArgs) => {
                    clicked = buttonArgs.ButtonIndex;
                    if (clicked == 1)
                    {
                        reloading = false;
                        loadDataServer();
                    }
                };
            }
            else if (gotoEvent)
            {
                var detail = new UIEventDetail(true);
                detail.key   = keyEvent;
                detail.Title = "Eventi";
                this.NavigationController.PushViewController(detail, true);
            }



            // Perform any additional setup after loading the view, typically from a nib.
        }
Example #3
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            System.Threading.Thread.Sleep(1500);              //splash time

            Parse.SetAppId(appid, clientid);

            /*
             * WithValidParseIds (delegate {
             *  Parse.SetApplicationIdClientKey (appid, clientid);
             *
             * });;
             */

            //loadData ();

            var controller = new UIHomeScreen();

            int firstTime = NSUserDefaults.StandardUserDefaults.IntForKey("firstTime");

            firstTime++;

            NSUserDefaults.StandardUserDefaults.SetInt(firstTime, "firstTime");
            controller.firstTime = firstTime;

            navigationController      = new UINavigationController(controller);
            window.RootViewController = navigationController;

            try
            {
                if (options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")))
                {
                    NSDictionary aps = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary;

                    Console.WriteLine("entro aqui...");

                    string alert = "NADA";

                    if (aps.ContainsKey(new NSString("alert")))
                    {
                        Console.WriteLine("trae alert aqui...");

                        alert = (aps [new NSString("alert")] as NSString).ToString();

                        alert = alert.Replace("Nuovo evento creato: ", "");

                        app.ApplicationIconBadgeNumber = 0;

                        app.CancelAllLocalNotifications();//.ca

                        controller.gotoEvent = true;
                        controller.keyEvent  = alert;


                        var x = new UIAlertView("iPortogruaro", "Un nuovo evento รจ stato creato vuoi vedere?", null, "Annullare", "Ok");
                        x.Show();

                        x.Clicked += (sender, buttonArgs) => {
                            int clicked = buttonArgs.ButtonIndex;

                            if (clicked == 1)
                            {
                                var detail = new UIEventDetail(true);
                                detail.key   = alert;
                                detail.Title = "Eventi";
                                this.navigationController.PushViewController(detail, true);
                                //ReceivedRemoteNotification (app, aps);
                            }
                        };
                    }
                    else if (aps.ContainsKey(new NSString("aps")))
                    {
                        Console.WriteLine("NSDictionary: 123");

                        NSDictionary aps2 = aps.ObjectForKey(new NSString("aps")) as NSDictionary;

                        Console.WriteLine("NSDictionary: " + aps2.ToString());
                        alert = (aps2 [new NSString("alert")] as NSString).ToString();

                        alert = alert.Replace("Nuovo evento creato: ", "");

                        Console.WriteLine(alert);

                        app.ApplicationIconBadgeNumber = 0;

                        app.CancelAllLocalNotifications(); //.ca

                        controller.gotoEvent = true;
                        controller.keyEvent  = alert;
                        var detail = new UIEventDetail(true);
                        detail.key   = alert;
                        detail.Title = "Eventi";
                        this.navigationController.PushViewController(detail, true);
                    }
                    else
                    {
                        /*
                         * {
                         * aps =     {
                         * alert = "Nuovo evento creato: Evento Prova Gi\U00f2";
                         * };
                         * }
                         */



                        Console.WriteLine("NSDictionary: " + aps.ToString());

                        JsonValue value = JsonObject.Parse(aps.ToString());

                        Console.WriteLine(value.ToString());

                        JsonValue ar  = value ["aps"];
                        string    msg = "";

                        foreach (JsonValue v in ar)
                        {
                            msg = v ["alert"].ToString().Replace("\"", "");


                            Console.WriteLine("json parse: " + msg);
                        }

                        controller.gotoEvent = true;
                        controller.keyEvent  = msg;
                    }
                }
            }
            catch (Exception ex) {
                Console.WriteLine("error geting the push notifications Error: " + ex.Message);


                if (controller == null)
                {
                    controller = new UIHomeScreen();



                    navigationController      = new UINavigationController(controller);
                    window.RootViewController = navigationController;
                }
            }
            //20130711 start
            if (window.RootViewController == null)
            {
                controller                = new UIHomeScreen();
                navigationController      = new UINavigationController(controller);
                window.RootViewController = navigationController;
            }
            //20130711 end

            // make the window visible
            window.MakeKeyAndVisible();

            //ValidateSetup ();
            //SetupUI ();
            GetLocation();

            //string  newDeviceToken =  NSUserDefaults.StandardUserDefaults.StringForKey("PushDeviceToken");

            //Console.WriteLine("Device Token: " + newDeviceToken);

            registerNotifications();

            return(true);
        }
Example #4
0
 public browserDelegateevent(UIEventDetail controller) : base()
 {
     _vc = controller;
 }