Ejemplo n.º 1
0
        public void UnregisterFromAzurePushNotification()
        {
            if (MainActivityInstance == null)
            {
                Log.Info("MainActivityInstance", "MainActivityInstance = null;");

                throw new Exception("You need to set AzurePushNotificationImplementation.MainActivityInstance to your MainActivity inside MainActivity.cs.");
            }

            try
            {
                // Check to ensure everything's set up right
                GcmClient.CheckDevice(MainActivityInstance);
                GcmClient.CheckManifest(MainActivityInstance);

                // Register for push notifications
                Log.Info("MainActivity", "Unregistering...");

                GcmClient.UnRegister(MainActivityInstance);

                Log.Info("MainActivity", "Completed unregistering.");
            }
            catch (Exception exc)
            {
                Log.Info("Exception : ", exc.Message);
            }
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.FirstView);

            // Make sure the device support for google play services
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            // Register the app for push notifications.
            GcmClient.Register(this, Receiver.senderIDs);

            TabHost.TabSpec spec;

            spec = TabHost.NewTabSpec("search");
            spec.SetIndicator("", Resources.GetDrawable(Resource.Drawable.indicator_search));
            spec.SetContent(this.CreateIntentFor(FirstViewModel.Search));
            TabHost.AddTab(spec);

            spec = TabHost.NewTabSpec("recent");
            spec.SetIndicator("", Resources.GetDrawable(Resource.Drawable.indicator_history));
            spec.SetContent(this.CreateIntentFor(FirstViewModel.Recent));
            TabHost.AddTab(spec);

            spec = TabHost.NewTabSpec("favourite");

            spec.SetIndicator("", Resources.GetDrawable(Resource.Drawable.indicator_favorite));
            spec.SetContent(this.CreateIntentFor(FirstViewModel.Favourite));
            TabHost.AddTab(spec);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            Xamarin.FormsMaps.Init(this, bundle);
            SecureStorageImplementation.StoragePassword = Build.Id;
            global::Xamarin.Forms.Forms.Init(this, bundle);
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            CurrentActivity = this;
            LoadApplication(new App());

            try
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Nos registramos por notificaciones push
                System.Diagnostics.Debug.WriteLine("Registrando...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                System.Diagnostics.Debug.WriteLine("Error creando el cliente. Verifica la URL.");
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            instance = this;

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            LoadApplication(new App());

            try
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                System.Diagnostics.Debug.WriteLine("Registrando...");
                GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                createAndShowDialog("Url inválida", "Erro");
            }
            catch (Exception e)
            {
                createAndShowDialog(e.Message, "Erro");
            }
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            AzurePushNotificationsImplementation.Init(this);
            //Validate if Play Services are supported in the system.
            var gpsAvailable = IsPlayServicesAvailable();

            //Settings.Current.IsPushEnabled = gpsAvailable;
            if (gpsAvailable)
            {
                // Check to ensure everything's set up right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);
                // Register for push notifications
                StartService(new Intent(this, typeof(PNRegistrationService)));
            }

            LoadApplication(new App(new AndroidInitializer()));
        }
Ejemplo n.º 6
0
        public async Task InitializeNotificationsAsync()
        {
            try
            {
                // If already registered, then just return so that we only register for push notications once
                if (Locator.Instance.IsPushNotificationsRegistered)
                {
                    return;
                }

                // Check to ensure everything's setup right
                GcmClient.CheckDevice(MainActivity.CurrentActivity);
                GcmClient.CheckManifest(MainActivity.CurrentActivity);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(MainActivity.CurrentActivity, PushHandlerBroadcastReceiver.SENDER_IDS);

                Locator.Instance.IsPushNotificationsRegistered = true;
            }
            catch (Exception e)
            {
                Locator.Instance.IsPushNotificationsRegistered = false;

                CreateAndShowDialog("Registration for push notifications failed:\n\n" + e.Message + "\n\nIf this app is running in an emmulator, make sure that you are deploying to or debugging on a virtual device that has Google APIs set as the target", "Error - Push Registration Failed");
            }
        }
Ejemplo n.º 7
0
        private async void RegisterForNotifications()
        {
            GcmClient.CheckDevice(this.ApplicationContext);
            GcmClient.CheckManifest(this.ApplicationContext);

            GcmClient.Register(this.ApplicationContext, Constants.GCMProjectIdentifier);
        }
Ejemplo n.º 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            instance = this;
            CurrentPlatform.Init();

            todoItemManager = new ToDoItemManager();
            App.SetTodoItemManager(todoItemManager);

            LoadApplication(new App());

            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }
Ejemplo n.º 9
0
        public void StartRegisterDevice(Context ctx)
        {
            GcmClient.CheckDevice(ctx);
            GcmClient.CheckManifest(ctx);

            if (!GcmClient.IsRegistered(ctx))
            {
                try
                {
                    string projectId;
                    try
                    {
                        _host     = _host.ToCurrentScheme(false);
                        projectId = GetGoogleProjectId();
                    }
                    catch (WebException e)
                    {
                        _host     = _host.ToCurrentScheme(true);
                        projectId = GetGoogleProjectId();
                    }

                    GcmBroadcastReceiver.SenderIds = new[] { projectId };
                    GcmClient.Register(ctx, GcmBroadcastReceiver.SenderIds);
                }
                catch (Exception e)
                {
                    _applicationContext.HandleException(e);
                }
            }
        }
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init();

            // Create the Mobile Service Client instance, using the provided
            // Mobile Service URL
            client = new MobileServiceClient(applicationURL);
            await InitLocalStoreAsync();

            // Set the current instance of TodoActivity.
            instance = this;

            // Make sure the GCM client is set up correctly.
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            // Get the Mobile Service sync table instance to use
            toDoTable = client.GetSyncTable <ToDoItem> ();

            textNewToDo = FindViewById <EditText> (Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById <ListView> (Resource.Id.listViewToDo);

            listViewToDo.Adapter = adapter;

            //// Load the items from the Mobile App backend.
            //OnRefreshItemsSelected ();
        }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            Button button = FindViewById <Button>(Resource.Id.btnLogin);

            button.Click += btnGiris_Click;

            txtUsername = FindViewById <EditText>(Resource.Id.txtKullaniciAdi);
            txtPassword = FindViewById <EditText>(Resource.Id.txtPassword);

            Intent servIntent = new Intent(ApplicationContext, typeof(LocationControlService));

            StartService(servIntent);

            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);
            Firebase.FirebaseApp.InitializeApp(this);
            Thread.Sleep(1000);

            //FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
            //         fab.Click += FabOnClick;
        }
Ejemplo n.º 12
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            SecureStorageImplementation.StoragePassword = Build.Id;
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            global::Xamarin.Forms.Forms.Init(this, bundle);
            ImageCircleRenderer.Init();
            LoadApplication(new App());

            try
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, GcmService.SenderId);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
Ejemplo n.º 13
0
		public static async Task<bool> RegisterService(Context context)
		{
			try
			{
				// Check to ensure everything's set up right
				GcmClient.CheckDevice(context);
				GcmClient.CheckManifest(context);

				// Register for push notifications
				System.Diagnostics.Debug.WriteLine("Registering...");
				GcmClient.Register(context, PushHandlerBroadcastReceiver.SENDER_IDS);
				return await Task.Run(() => true);
			}
			catch (Java.Net.MalformedURLException) 
			{
                if (context is MainActivity)
				    (context as MainActivity).CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");

                return await Task.Run(() => false);
			}
			catch (Exception e)
			{
				if (context is MainActivity)
					(context as MainActivity).CreateAndShowDialog(e.Message, "Error");

                return await Task.Run(() => false);
			}
		}
Ejemplo n.º 14
0
 public void Start(string userName)
 {
     this.userName = userName;
     GcmClient.CheckDevice(context);
     GcmClient.CheckManifest(context);
     GcmClient.Register(context, Constants.ProjectId);
 }
Ejemplo n.º 15
0
        private void RegisterForPushNotifications()
        {
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);
        }
Ejemplo n.º 16
0
        private ProgressBar progressBar;                  // Progress spinner to use for table operations

        // Called when the activity initially gets created
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
            progressBar            = FindViewById <ProgressBar>(Resource.Id.loadingProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

                CurrentPlatform.Init();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    Constants.ApplicationURL,
                    Constants.ApplicationKey, progressHandler);

                // Get the Mobile Service Table instance to use
                todoTable = client.GetTable <TodoItem>();

                textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

                // Create an adapter to bind the items with the view
                adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);
                listViewTodo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }
Ejemplo n.º 17
0
        protected override void OnCreate(Bundle bundle)
        {
            instance = this;

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            ImageCircleRenderer.Init();
            LoadApplication(new App());

            try
            {
                //instalado a library GcmClient e verificamos se está tudo Ok
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception ex)
            {
                CreateAndShowDialog(ex.Message, "Error");
            }
        }
Ejemplo n.º 18
0
        protected override void OnCreate(Bundle bundle)
        {
            // GCM
            instance = this;
            /////

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            LoadApplication(new DontBeDoryApp.App());
            MobileAds.Initialize(ApplicationContext, "ca-app-pub-8521044456540023~7459937605");

            // GCM
            try
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            CurrentActivity = this;
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();
            LoadApplication(new App());

            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
Ejemplo n.º 20
0
        void RegisterGCM()
        {
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            GcmClient.Register(this, NotificationConstants.SenderId);
        }
        protected override void OnCreate(Bundle bundle)
        {
            // GCM
            instance = this;
            /////

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());

            // GCM
            try
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
Ejemplo n.º 22
0
        protected override void OnCreate(Bundle bundle)
        {
            // Push Notification: inicializando a instancia do MainActivity.
            instance = this;

            base.OnCreate(bundle);

            // Initialize Azure Mobile Apps
            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            // Initialize Xamarin Forms
            global::Xamarin.Forms.Forms.Init(this, bundle);

            // Load the main application
            LoadApplication(new App());

            // Push Notification
            try {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Registra a mensagem no push notifications
                System.Diagnostics.Debug.WriteLine("Enviando...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException) {
                CreateAndShowDialog("Ocorreu um erro inesperado. Verifique a URL", "Falha");
            }
            catch (Exception e) {
                CreateAndShowDialog(e.Message, "Falha");
            }

            App.Init((IAuthenticate)this);
        }
Ejemplo n.º 23
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            CurrentActivity = this;
            Forms.Init(this, bundle);
            CurrentPlatform.Init();
            App.Init(this);
            new SfRatingRenderer();
            new SfCalendarRenderer();

            ZXing.Net.Mobile.Forms.Android.Platform.Init();
            UserDialogs.Init(() => this);
            FormsVideoPlayer.Init();
            LoadApplication(new App());
            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (System.Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
        private void RegistrarApp(Context applicationContext)
        {
            GcmClient.CheckDevice(applicationContext);
            GcmClient.CheckManifest(applicationContext);

            GcmClient.Register(applicationContext, Constantes.SenderId);
        }
Ejemplo n.º 25
0
        protected override void OnCreate(Bundle bundle)
        {
            // Set the current instance of MainActivity.
            instance = this;

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            Xamarin.Forms.Forms.Init(this, bundle);
            Xamarin.FormsMaps.Init(this, bundle);
            App.Init((IAuthenticate)this);
            LoadApplication(new App());

            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.Message, "Error");
            }
        }
Ejemplo n.º 26
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            FormsAppCompatActivity.ToolbarResource   = Resource.Layout.Toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;

            // iconify init
            Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.MaterialModule());
            FormsPlugin.Iconize.Droid.IconControls.Init();

            // xlabs init
            var container = new SimpleContainer();

            container.Register <IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register <IDisplay>(t => t.Resolve <IDevice>().Display);
            container.Register <INetwork>(t => t.Resolve <IDevice>().Network);
            Resolver.SetResolver(container.GetResolver());

            global::Xamarin.Forms.Forms.Init(this, bundle);

            // xamarin plugins init
            ImageCircleRenderer.Init();

            // init gcm client
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);

            //Call to Register the device for Push Notifications
            GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);

            LoadApplication(new App());
        }
Ejemplo n.º 27
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            CurrentPlatform.Init();

            // Create the client instance, using the mobile app backend URL.
            client = new MobileServiceClient(applicationURL);
#if OFFLINE_SYNC_ENABLED
            await InitLocalStoreAsync();

            // Get the sync table instance to use to store TodoItem rows.
            todoTable = client.GetSyncTable <ToDoItem>();
#else
            todoTable = client.GetTable <ToDoItem>();
#endif

            textNewToDo = FindViewById <EditText>(Resource.Id.textNewToDo);

            // Create an adapter to bind the items with the view
            adapter = new ToDoItemAdapter(this, Resource.Layout.Row_List_To_Do);
            var listViewToDo = FindViewById <ListView>(Resource.Id.listViewToDo);
            listViewToDo.Adapter = adapter;

            ToDoActivity.instance = this;
            GcmClient.CheckDevice(this); GcmClient.CheckManifest(this);

            GcmClient.Register(this, ToDoBroadcastReceiver.senderIDs);
            // Load the items from the mobile app backend.
            OnRefreshItemsSelected();
        }
Ejemplo n.º 28
0
        public override void OnCreate()
        {
            base.OnCreate();

            var config = new ImageLoaderConfiguration.Builder(this)
                         .MemoryCacheExtraOptions(DroidConstants.ImageSize, DroidConstants.ImageSize) // default = device screen dimensions
                         .DiskCacheExtraOptions(DroidConstants.ImageSize, DroidConstants.ImageSize, null)
                         .ThreadPoolSize(10)                                                          // default
                         .ThreadPriority(Thread.NormPriority - 2)                                     // default
                         .TasksProcessingOrder(QueueProcessingType.Fifo)                              // default
                         .MemoryCacheSize(20 * 1024 * 1024)
                         .MemoryCacheSizePercentage(30)                                               // default
                         .DiskCacheSize(50 * 1024 * 1024)
                         .DiskCacheFileCount(300)
                         .WriteDebugLogs()
                         .Build();

            ImageLoader.Instance.Init(config);
            Crittercism.Init(ApplicationContext, "1c2c97937d6f4d0aa6235204ae512f4000555300");

            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);
            GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);

            var handler = new ApplicationLifecycleHandler();

            RegisterActivityLifecycleCallbacks(handler);
            RegisterComponentCallbacks(handler);
        }
Ejemplo n.º 29
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

            App.UIContext = this;
            LoadApplication(new ContosoInsurance.App());

            instance = this;

            #if PUSH // need to use a Google image on an Android emulator
            try {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
            }
            catch (Java.Net.MalformedURLException) {

                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e) {
                CreateAndShowDialog(e, "Error");
            }
            #endif
        }
Ejemplo n.º 30
0
        /// <summary>
        /// For Android project, obj must be the MainActivity.
        /// </summary>
        /// <param name="obj"></param>
        public void RegisterForAzurePushNotification()
        {
            if (MainActivityInstance == null)
            {
                Log.Info("MainActivityInstance", "MainActivityInstance = null;");

                throw new Exception("You need to set AzurePushNotificationImplementation.MainActivityInstance to your MainActivity inside MainActivity.cs before calling LoadApplication(new App());");
            }

            try
            {
                // Check to ensure everything's set up right
                GcmClient.CheckDevice(MainActivityInstance);
                GcmClient.CheckManifest(MainActivityInstance);

                // Register for push notifications
                Log.Info("MainActivity", "Registering...");

                GcmClient.Register(MainActivityInstance, MyBroadcastReceiver.SENDER_IDS);

                Log.Info("MainActivity", "Completed Registering.");
            }
            catch (Exception exc)
            {
                Log.Info("Exception : ", exc.Message);
            }
        }