Example #1
0
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     CoreUtility.ExecuteMethod("DidRegisterUserNotificationSettings", delegate()
     {
         application.RegisterForRemoteNotifications(); // second part, first from viewplatform
     });
 }
Example #2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            DependencyService.Register <IosDeviceRegistration>();

            var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);

            app.RegisterUserNotificationSettings(notificationSettings);
            app.RegisterForRemoteNotifications();



            UILocalNotification notification = new UILocalNotification();

            notification.FireDate = NSDate.FromTimeIntervalSinceNow(3600);
            //notification.AlertTitle = "Alert Title"; // required for Apple Watch notifications
            notification.AlertAction = "View Alert";
            notification.AlertBody   = "Сашка, я тебя люблю!";
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);



            return(base.FinishedLaunching(app, options));
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            var apiKey = loadApiKey();

            NITManager.SetupWithApiKey(apiKey);
            NITManager.DefaultManager.SetDeferredUserDataWithKey("os", "iOS");

            UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert, (approved, err) => {
            });
            UNUserNotificationCenter.Current.Delegate = new UserNotificationDelegate();

            EventContent   ec  = new EventContent();
            ItemsViewModel ivm = new ItemsViewModel();

            LocationPermission();

            app.RegisterForRemoteNotifications();

            NITManager.DefaultManager.SetDeferredUserDataWithKey("age", "24");
            NITManager.DefaultManager.SetDeferredUserDataWithKey("name", "John");

            return(base.FinishedLaunching(app, options));
        }
Example #4
0
 public static void InitNotification(UIApplication app, NSDictionary options)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
     {
         var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
             UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
             );
         app.RegisterUserNotificationSettings(notificationSettings);
         app.RegisterForRemoteNotifications();
     }
     else
     {
         UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
         UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
     }
     if (options != null)
     {
         // check for a remote notification
         if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
         {
             NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
             if (remoteNotification != null)
             {
                 var body = remoteNotification.Values[0].ValueForKey(new NSString("alert")).ValueForKey(new NSString("body")).ToString();
                 OnRemoteNotification(body);
             }
         }
     }
 }
Example #5
0
        public override bool FinishedLaunching(UIApplication nativeApp, NSDictionary options)
        {
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            Xamarin.Forms.Forms.Init();

            this.formsApp = new PushNotifClient.App();
            LoadApplication(this.formsApp);

            // Guidelines for notifications: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/Introduction.html#//apple_ref/doc/uid/TP40008194

            // App must ask the user for permission, no matter if we're using local or remote notifications.
            // There is also RegisterForRemoteNotificationTypes() but it is deprecated in iOS8.
            // NOTE: !Push notifications are not supported on the iOS Simulator!

            nativeApp.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(
                                                           UIUserNotificationType.Alert
                                                           | UIUserNotificationType.Badge
                                                           | UIUserNotificationType.Sound,
                                                           null));

            // Request registration for remote notifications. This will talk to Apple's push server and the app will receive a token
            // when RegisteredForRemoteNotifications() gets called. This call is non-blocking.
            nativeApp.RegisterForRemoteNotifications();

            return(base.FinishedLaunching(nativeApp, options));
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            ImageCircleRenderer.Init();

            snsClient = new AmazonSimpleNotificationServiceClient(new CognitoAWSCredentials(
                                                                      Keys.AWSCognito,
                                                                      RegionEndpoint.USEast1), RegionEndpoint.USEast1);

            var manager = BITHockeyManager.SharedHockeyManager;

            manager.Configure(Keys.HockeyApp);
            manager.StartManager();

            LoadApplication(new App());

            var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert |
                UIUserNotificationType.Badge |
                UIUserNotificationType.Sound,
                null
                );

            app.RegisterUserNotificationSettings(pushSettings);
            app.RegisterForRemoteNotifications();


            var x = typeof(Xamarin.Forms.Themes.DarkThemeResources);

            x = typeof(Xamarin.Forms.Themes.LightThemeResources);
            x = typeof(Xamarin.Forms.Themes.iOS.UnderlineEffect);
            return(base.FinishedLaunching(app, options));
        }
Example #7
0
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Alert, null);
			application.RegisterUserNotificationSettings (notificationSettings);
			application.RegisterForRemoteNotifications ();

			return true;
		}
Example #8
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new SNSPushNotification.App());

            app.RegisterForRemoteNotifications();

            return(base.FinishedLaunching(app, options));
        }
Example #9
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert, null);

            application.RegisterUserNotificationSettings(notificationSettings);
            application.RegisterForRemoteNotifications();

            return(true);
        }
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			#if DEBUG
			Xamarin.Calabash.Start();
			#endif


			// create our window
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.MakeKeyAndVisible ();

			home = new Screens.iPhone.Home.Home_iPhone();
			home.View.Frame = new CoreGraphics.CGRect (0, UIApplication.SharedApplication.StatusBarFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height);
			window.RootViewController = home;

			// check for a notification
			if(options != null) {

				// check for a local notification
				if(options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) {

					UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
					if(localNotification != null) {

						new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
						// reset our badge
						UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
					}
				}

				// check for a remote notification
				if(options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) {

					NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
					if(remoteNotification != null) {
						//new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
					}
				}
			}

			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (
					                           UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
				                           );

				app.RegisterUserNotificationSettings (notificationSettings);
				app.RegisterForRemoteNotifications ();
			} else {
				//==== register for remote notifications and get the device token
				// set what kind of notification types we want
				UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
				// register for remote notifications
				UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
			}

			return true;
		}
Example #11
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// Override point for customization after application launch.
			UIUserNotificationSettings notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Alert, null);
			app.RegisterUserNotificationSettings (notificationSettings);;
			app.RegisterForRemoteNotifications ();

			return true;
		}
        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new SNSPushNotification.App());

            app.RegisterForRemoteNotifications();

            return base.FinishedLaunching(app, options);
        }
Example #13
0
        public override bool WillFinishLaunching(UIApplication application, NSDictionary launchOptions)
        {
            application.RegisterForRemoteNotifications();

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    //OS is up to date
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    //welcome the user when they launch the app for the first time on the device
                    //add a key to the OS

                    return(true);
                }
                else
                {
                    //OS is out of date
                    return(false);
                }
                return(true);
            }

            else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    //local notifications
                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    Console.WriteLine("Current controller is: " + this.navMaster.VisibleViewController);
                    return(true);
                }
            }
            return(true);
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create our window
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.MakeKeyAndVisible();

            home                      = new Screens.iPhone.Home.Home_iPhone();
            home.View.Frame           = new CoreGraphics.CGRect(0, UIApplication.SharedApplication.StatusBarFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height);
            window.RootViewController = home;

            // check for a notification
            if (options != null)
            {
                // check for a local notification
                if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }

                // check for a remote notification
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                        //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                app.RegisterUserNotificationSettings(notificationSettings);
                app.RegisterForRemoteNotifications();
            }
            else
            {
                //==== register for remote notifications and get the device token
                // set what kind of notification types we want
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                // register for remote notifications
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

            return(true);
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // check for a notification

            if (options != null)
            {
                // check for a local notification
                if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }

                // check for a remote notification
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                        //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                app.RegisterUserNotificationSettings(notificationSettings);
                app.RegisterForRemoteNotifications();
            }
            else
            {
                //==== register for remote notifications and get the device token
                // set what kind of notification types we want
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                // register for remote notifications
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }



            WireUpLongRunningTask();

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App(null));

            return(base.FinishedLaunching(app, options));
        }
Example #16
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Override point for customization after application launch.
            UIUserNotificationSettings notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert, null);

            app.RegisterUserNotificationSettings(notificationSettings);;
            app.RegisterForRemoteNotifications();

            return(true);
        }
        void SetupPushNotifications(UIApplication app, NSDictionary options)
        {
            var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);

            app.RegisterUserNotificationSettings(pushSettings);
            app.RegisterForRemoteNotifications();

            ProcessNotification(options, false);
        }
Example #18
0
 /// <summary>
 /// 注册苹果推送,获取deviceToken用于推送
 /// </summary>
 static void RegisterAPNS(UIApplication application)
 {
     if (System.Convert.ToDouble(UIDevice.CurrentDevice.SystemVersion) >= 8.0)
     {
         // iOS 8 Notifications
         application.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, null));
         application.RegisterForRemoteNotifications();
     }
     else
     {
         // iOS < 8 Notifications
         UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound);
     }
 }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            UIApplication.SharedApplication
            .SetMinimumBackgroundFetchInterval(10);

            var settings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.None, null);

            application.RegisterUserNotificationSettings(settings);
            application.RegisterForRemoteNotifications();

            return(true);
        }
Example #20
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            App.IsNeedMargin = GetNeedBezelPadding();
            LoadApplication(new App());


            if (Const.Offline)
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    App.Transition(new StartPage());
                });
            }
            else
            {
                Firebase.Core.App.Configure();
                Messaging.SharedInstance.Delegate          = this;
                RemoteConfig.SharedInstance.ConfigSettings = new RemoteConfigSettings(false);
                FetchRemoteConfigFromServer();
                MobileAds.Configure(Const.AdMobID);
                DependencyService.Get <IDeviceService>().LoadAd();

#if !DEBUG
                var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);
                app.RegisterUserNotificationSettings(settings);
                app.RegisterForRemoteNotifications();
                UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
#endif

                Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                {
                    var canUseStore = await StorageService.Initialize();
                    if (!canUseStore)
                    {
                        await App.ShowMessage("現在ご利用できません");
                        throw new Exception("Firebase setup failed");
                    }
                    App.Transition(new StartPage());
                });
            }

            AnimationViewRenderer.Init();
            return(base.FinishedLaunching(app, options));
        }
Example #21
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            LoadApplication(new App());

            var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert |
                UIUserNotificationType.Badge |
                UIUserNotificationType.Sound,
                null
                );

            app.RegisterUserNotificationSettings(pushSettings);

            app.RegisterForRemoteNotifications();

            return(base.FinishedLaunching(app, options));
        }
Example #22
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            //Profile.EnableUpdatesOnAccessTokenChange(true);
            //Settings.AppID = appId;
            //Settings.DisplayName = appName;


            //TODO:push notification falta integrar ios
            app.UnregisterForRemoteNotifications();
            var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert |
                UIUserNotificationType.Badge |
                UIUserNotificationType.Sound,
                null
                );

            app.RegisterUserNotificationSettings(pushSettings);
            app.RegisterForRemoteNotifications();


            UISwitch.Appearance.OnTintColor = Color.FromHex("#548EBD").ToUIColor();

            UINavigationBar.Appearance.TintColor = Color.White.ToUIColor();
            //establecer color de fondo sin esto, al levantar el album de photos no se distinguen los titulos
            UINavigationBar.Appearance.BarTintColor = Color.FromHex("#1C5885").ToUIColor();
            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
            {
                TextColor = UIColor.White
            });
            //PlotProjects.Plugin.Plot.GetInstance(options, true);
            ImageCircleRenderer.Init();
            Xamarin.FormsMaps.Init();
            Xamarin.IQKeyboardManager.SharedManager.Enable = true;
            //IQKeyboardManager.SharedManager.Enable = true;

            App.CurrentVersion = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString();

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Example #23
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            string a = "f";

            NITManager.SetupWithApiKey("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5MWMxYzViYzUxODU0ZjE0OGYzYWNiNmQ4YmE4NzU0ZiIsImlhdCI6MTUwNjQxODE2MCwiZXhwIjoxNjMyNzAwNzk5LCJkYXRhIjp7ImFjY291bnQiOnsiaWQiOiIxN2YxMjJiNi1iZjUwLTQ4ZGQtOWZiYi00OTVjMjc4OTZmMzkiLCJyb2xlX2tleSI6ImFwcCJ9fX0.b6AUrbcuwiPJNpY2f7gGH3Qi6s3ZTfCMALqTPwyjJxA");
            NITManager.SetFrameworkName("xamarin");
            NITManager d = NITManager.DefaultManager;

            CLLocationManager c = new CLLocationManager();

            c.RequestAlwaysAuthorization();
            application.RegisterForRemoteNotifications();

            UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert, (approved, err) => {
            });
            UNUserNotificationCenter.Current.Delegate = new UserNotificationDelegate();

            return(true);
        }
Example #24
0
 public void ConfigureNotifications(UIApplication app)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
     {
         var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
         UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (approved, err) =>
         {
             if (approved)
             {
                 UNUserNotificationCenter.Current.Delegate = this;
                 DispatchQueue.MainQueue.DispatchAsync(() => {
                     app.RegisterForRemoteNotifications();
                 });
             }
         });
     }
     else
     {
         var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
         var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
         UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
     }
 }
Example #25
0
        public static void Register(UIApplication application = null)
        {
            if (application == null)
            {
                application = UIApplication.SharedApplication;
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Sound |
                                                                              UIUserNotificationType.Alert | UIUserNotificationType.Badge, null);

                application.RegisterUserNotificationSettings(settings);
                application.RegisterForRemoteNotifications();
            }
            //else
            //{
            //    application.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Badge |
            //        UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert);
            //}
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    Console.WriteLine(error?.Description);
                });

                UNUserNotificationCenter.Current.Delegate = new UserPushNotificationCenterDelegate();
            }
            else
            {
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }
        }
Example #26
0
        public override void FinishedLaunching(UIApplication application)
        {
            application.RegisterForRemoteNotifications();


            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    //OS is up to date
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                    try
                    {
                        if (filePathPassword == null)
                        {
                            throw new FileNotFoundException();
                        }
                        else
                        {
                            if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                            {
                                if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                                {
                                    this.Window.RootViewController = this.passwordFirstControl;
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                            }
                            else
                            {
                                if (this.navMaster.ViewControllers.Contains(this.password) == true)
                                {
                                    if (this.navMaster.VisibleViewController != this.password)
                                    {
                                        this.passwordLog.Text = "";
                                        this.passwordLog.ResignFirstResponder();
                                        this.navMaster.PopToViewController(this.password, true);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Controller already exists");
                                    }
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.password, true);
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                        {
                            this.Window.RootViewController = this.password;
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                    }
                    //welcome the user when they launch the app for the first time on the device
                    //add a key to the OS
                    Console.WriteLine("Presented view controller" + this.navMaster.VisibleViewController);
                }
                else
                {
                    //OS is out of date
                }
            }

            else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    //local notifications
                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                    try
                    {
                        if (filePathPassword == null)
                        {
                            throw new FileNotFoundException();
                        }
                        else
                        {
                            if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                            {
                                if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                                {
                                    this.Window.RootViewController = this.passwordFirstControl;
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                            }
                            else
                            {
                                if (this.navMaster.ViewControllers.Contains(this.password) == true)
                                {
                                    if (this.navMaster.VisibleViewController != this.password)
                                    {
                                        this.passwordLog.Text = "";
                                        this.passwordLog.ResignFirstResponder();
                                        this.navMaster.PopToViewController(this.password, true);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Controller already exists");
                                    }
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.password, true);
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                        {
                            this.Window.RootViewController = this.password;
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                    }
                    Console.WriteLine("Presented view controller" + this.navMaster.VisibleViewController);
                }
            }
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            //global::Xamarin.Forms.FormsMaterial.Init();
            Xamarin.FormsGoogleMaps.Init(MapsApiKey);

            LoadApplication(new App());

            /*
             * FirebasePushNotificationManager.Initialize(options, new NotificationUserCategory[]
             * {
             *  new NotificationUserCategory("message",new List<NotificationUserAction> {
             *      new NotificationUserAction("Reply","Reply",NotificationActionType.Foreground)
             *  }),
             *  new NotificationUserCategory("request",new List<NotificationUserAction> {
             *      new NotificationUserAction("Accept","Accept"),
             *      new NotificationUserAction("Reject","Reject",NotificationActionType.Destructive)
             *  })
             *
             * });
             */

            // check for a notification
            if (options != null)
            {
                // check for a local notification
                if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }

                // check for a remote notification
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                        //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                app.RegisterUserNotificationSettings(notificationSettings);
                app.RegisterForRemoteNotifications();
            }
            else
            {
                //==== register for remote notifications and get the device token
                // set what kind of notification types we want
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                // register for remote notifications
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

            return(base.FinishedLaunching(app, options));
        }
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{ 
			//application.RegisteredForRemoteNotifications (application);
			SystemLogger.Log (SystemLogger.Module.PLATFORM, "DidRegisterUserNotificationSettings from AppDelegate..."); 
			application.RegisterForRemoteNotifications (); 
		}
Example #29
0
        //resturar paquetes,   actualizar    limpiar compilar   revisar que el infop.list este en 8
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            ZXing.Net.Mobile.Forms.iOS.Platform.Init();
            //paypal produccion AQrrFs8D-iSCYiAEEmO9ni3CcQ7GjgjPqSBBVhxNTmRKOnLR_Ol_qRcy2Pr4yxhwcQ2BK1BoZbzl0Hka
            //paypal sandbox  AVART2W6j2cnNhmWej6EcQjx_ytsVpl1hmnArzHtVWSsZFRVAWOlZq6y3EjPFM0FHUhG_yrvkftXAAtN
            var config = new PayPalConfiguration(PayPalEnvironment.Production, "AQrrFs8D-iSCYiAEEmO9ni3CcQ7GjgjPqSBBVhxNTmRKOnLR_Ol_qRcy2Pr4yxhwcQ2BK1BoZbzl0Hka")
                         //var config = new PayPalConfiguration(PayPalEnvironment.Sandbox, "AVART2W6j2cnNhmWej6EcQjx_ytsVpl1hmnArzHtVWSsZFRVAWOlZq6y3EjPFM0FHUhG_yrvkftXAAtN")
            {
                //If you want to accept credit cards
                AcceptCreditCards = false,
                //Your business name
                MerchantName = "Tienda",
                //Your privacy policy Url
                MerchantPrivacyPolicyUri = "http://tratoespecial.com/politicas-de-privacidad/",
                //Your user agreement Url
                MerchantUserAgreementUri = "http://tratoespecial.com/terminos-y-condiciones/",
                // OPTIONAL - ShippingAddressOption (Both, None, PayPal, Provided)
                ShippingAddressOption = ShippingAddressOption.Both,
                // OPTIONAL - Language: Default languege for PayPal Plug-In
                Language = "es",
                // OPTIONAL - PhoneCountryCode: Default phone country code for PayPal Plug-In
                PhoneCountryCode = "52",
            };

            CrossPayPalManager.Init(config);
            LoadApplication(new App());



            if (options != null)
            {
                //check for remote notification
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary _remoteNotif = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (_remoteNotif != null)
                    {
                        // new UIAlertView(_remoteNotif.a)
                    }
                }
            }

            // pedir permiso para enviar notificaciones
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                // iOS 8 or later
                var notifSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);

                // For iOS 8 display notification (sent via APNS)
                app.RegisterUserNotificationSettings(notifSettings);
                app.RegisterForRemoteNotifications();

                /*  UNUserNotificationCenter.Current.Delegate = this;
                 * System.Diagnostics.Debug.WriteLine($"antes 11: {app.IsRegisteredForRemoteNotifications.ToString()}");
                 * UIApplication.SharedApplication.RegisterForRemoteNotifications();
                 * System.Diagnostics.Debug.WriteLine($"despues 11: {app.IsRegisteredForRemoteNotifications.ToString()}");*/
            }
            else
            {
                //register for remote notifications and get the device token
                //set what kind of notifiaction type we want
                UIRemoteNotificationType _notifTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                //register for remtote notif
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(_notifTypes);

                /*var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                 * var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                 * UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                 * System.Diagnostics.Debug.WriteLine($"antes 9: {app.IsRegisteredForRemoteNotifications.ToString()}");
                 * UIApplication.SharedApplication.RegisterForRemoteNotifications();
                 * System.Diagnostics.Debug.WriteLine($"despues 9: {app.IsRegisteredForRemoteNotifications.ToString()}");*/
            }
            Firebase.Core.App.Configure();

            Firebase.InstanceID.InstanceId.Notifications.ObserveTokenRefresh((sender, e) =>
            {
                var newtoken = Firebase.InstanceID.InstanceId.SharedInstance.Token;
                System.Diagnostics.Debug.WriteLine($"FCM Token observe: {newtoken}");
                App.Fn_SetToken(newtoken);
            });
            //Firebase.InstanceID.InstanceId.TokenRefreshNotification;
            //debugAlert(UIApplication.SharedApplication.IsRegisteredForRemoteNotifications.ToString(),V_Token);
            // Console.WriteLine(" token device " + V_Token);
            //https://github.com/codercampos/FirebaseXF-XamarinLatino/blob/master/src/FirebaseXL/FirebaseXL.iOS/AppDelegate.cs        // blog.xamarians.com/blog/2017/9/18/firebase-cloud-messaging
            return(base.FinishedLaunching(app, options));
        }
Example #30
0
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{
			application.RegisterForRemoteNotifications();
		}
Example #31
0
 public void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     //application.RegisteredForRemoteNotifications (application);
     application.RegisterForRemoteNotifications();
 }
Example #32
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            // set our root view controller with the sidebar menu as the apps root view controller
            Window.RootViewController = new RootViewController();

            Window.MakeKeyAndVisible();

            #region Check for a Notification

            // check for a notification
            if (launchOptions != null)
            {
                // check for a local notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }

                // check for a remote notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                        //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                application.RegisterUserNotificationSettings(notificationSettings);
                application.RegisterForRemoteNotifications();
            }
            else
            {
                //==== register for remote notifications and get the device token
                // set what kind of notification types we want
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                // register for remote notifications
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

            var googleServiceDictionary = NSDictionary.FromFile("GoogleService-Info.plist");
            SignIn.SharedInstance.ClientID = googleServiceDictionary["CLIENT_ID"].ToString();
            #endregion

            //Profile.EnableUpdatesOnAccessTokenChange(true);
            //Settings.AppID = appId;
            //Settings.DisplayName = appName;
            //return ApplicationDelegate.SharedInstance.FinishedLaunching(application, launchOptions);
            return(true);
        }
 public void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     //application.RegisteredForRemoteNotifications (application);
     application.RegisterForRemoteNotifications ();
 }
Example #34
0
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     application.RegisterForRemoteNotifications();
 }
Example #35
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Log("Finished Launching");

            Log("Starting GCM");

            // Configure our core Google
            NSError err;

            Google.Core.Context.SharedInstance.Configure(out err);
            if (err != null)
            {
                Console.WriteLine("Failed to configure Google: {0}", err.LocalizedDescription);
            }
            Configuration = Google.Core.Context.SharedInstance.Configuration;

            // Configure and Start GCM
            var gcmConfig = Google.GoogleCloudMessaging.Config.DefaultConfig;

            gcmConfig.ReceiverDelegate = this;

            Service.SharedInstance.Start(gcmConfig);

            Log("Started GCM");

            Log("Registering for Remote Notifications");

            //// Register for remote notifications
            //var notTypes = UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge;
            //var settings = UIUserNotificationSettings.GetSettingsForTypes(notTypes, null);
            //UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            //UIApplication.SharedApplication.RegisterForRemoteNotifications();



            // registers for push
            var settings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert
                | UIUserNotificationType.Badge
                | UIUserNotificationType.Sound,
                new NSSet());

            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            UIApplication.SharedApplication.RegisterForRemoteNotifications();



            //// check for a notification
            if (launchOptions != null)
            {
                // check for a local notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localnotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localnotification != null)
                    {
                        //new UIAlertView(localnotification.AlertAction, localnotification.AlertBody, null, "ok", null).Show();
                        new UIAlertView("lauchOptions localnotification.AlertAction", "lauchOptions localnotification.AlertBody", null, "ok", null).Show();
                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }
                // check for a remote notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    //if (launchOptions != null)
                    {
                        alertNotification(application, remoteNotification);
                        //new UIAlertView("basdasdqrwqr", "adasdasd", null, "OK", null).Show();
                        //new UIAlertView("basdasdqrwqr", "adasdasd", null, "OK", null).Show();//remoteNotification["Body"].ToString()
                        //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
                    }
                }
            }


            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                    );

                application.RegisterUserNotificationSettings(notificationSettings);
                application.RegisterForRemoteNotifications();
            }
            else
            {
                //==== register for remote notifications and get the device token
                // set what kind of notification types we want
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
                // register for remote notifications
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }
            //end notifi

            return(true);
        }