예제 #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);
            }
        }
 public void UnregisterFromAzurePushNotification()
 {
     if (GcmClient.MainActivity != null)
     {
         GcmClient.UnRegister(GcmClient.MainActivity);
     }
 }
 public void UnregisterPush()
 {
     try
     {
         GcmClient.UnRegister(Application.Context);
     }
     catch (Exception ex)
     {
         Mvx.Resolve <IExceptionService>().HandleException(ex);
     }
 }
예제 #4
0
        private void UnRegisterWithGCM()
        {
            // Check to ensure everything's set up right
            GcmClient.CheckDevice(this);
            GcmClient.CheckManifest(this);


            // Register for push notifications
            Log.Info("MainActivity", "UnRegistering...");
            GcmClient.UnRegister(this);
        }
예제 #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);

            if (!onEmulator)
            {
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                if (!GcmClient.IsRegisteredOnServer(this))
                {
                    GcmClient.UnRegister(this);
                }
                GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);
            }

            this.uriText         = FindViewById <EditText>(Resource.Id.ServiceUri);
            this.tagsText        = FindViewById <EditText>(Resource.Id.ServiceTags);
            this.loginTestResult = FindViewById <TextView>(Resource.Id.LoginTestResult);

            this.uriText.Text  = prefs.GetString(Keys.MobileServiceUri, null);
            this.tagsText.Text = prefs.GetString(Keys.TagExpression, null);

            FindViewById <Button>(Resource.Id.RunTests).Click      += OnClickRunTests;
            FindViewById <Button>(Resource.Id.MSALogin).Click      += OnClickMicrosoftAccountLoginAndRefresh;
            FindViewById <Button>(Resource.Id.AADLogin).Click      += OnClickAADLoginAndRefresh;
            FindViewById <Button>(Resource.Id.GoogleLogin).Click   += OnClickGoogleLoginAndRefresh;
            FindViewById <Button>(Resource.Id.FacebookLogin).Click += OnClickFacebookLoginAndRefresh;
            FindViewById <Button>(Resource.Id.TwitterLogin).Click  += OnClickTwitterLoginAndRefresh;

            string autoStart = ReadSettingFromIntentOrDefault(Keys.AutoStart, "false");

            if (autoStart != null && autoStart.ToLower() == "true")
            {
                TestConfig config = new TestConfig
                {
                    MobileServiceRuntimeUrl               = ReadSettingFromIntentOrDefault(Keys.MobileServiceUri),
                    RuntimeVersion                        = ReadSettingFromIntentOrDefault(Keys.RuntimeVersion),
                    TagExpression                         = ReadSettingFromIntentOrDefault(Keys.TagExpression),
                    TestFrameworkStorageContainerUrl      = ReadSettingFromIntentOrDefault(Keys.StorageUrl),
                    TestFrameworkStorageContainerSasToken = ReadSettingFromIntentOrDefault(Keys.StorageSasToken)
                };
                App.Harness.SetAutoConfig(config);
                RunTests();
            }
        }
예제 #6
0
        private static Task <string> UnRegisterInternal()
        {
            unRegistrationTaskCompletionSource = new TaskCompletionSource <string>();

            try
            {
                GcmClient.UnRegister(initContext);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                unRegistrationTaskCompletionSource.TrySetResult(string.Empty);
            }

            return(unRegistrationTaskCompletionSource.Task);
        }
        /// <summary>
        /// Unregister from Azure Push Notifications
        /// </summary>
        /// <param name="cancellationToken">Token to cancel registration</param>
        public override Task <bool> UnregisterAsync(CancellationToken cancellationToken)
        {
            if (Tcs == null || Tcs.Task.IsCanceled || Tcs.Task.IsCompleted || Tcs.Task.IsFaulted)
            {
                Tcs = new TaskCompletionSource <bool>();
                cancellationToken.Register(() => Tcs.TrySetCanceled(), false);

                if (!_isInitialized)
                {
                    Initialize();
                }

                Debug.WriteLine($"Trying to unregister");
                GcmClient.UnRegister(CrossCurrentActivity.Current.Activity);
            }
            return(Tcs.Task);
        }
예제 #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            textRegistrationStatus = FindViewById <TextView>(Resource.Id.textRegistrationStatus);
            textRegistrationId     = FindViewById <TextView>(Resource.Id.textRegistrationId);
            textLastMsg            = FindViewById <TextView>(Resource.Id.textLastMessage);
            buttonRegister         = FindViewById <Button>(Resource.Id.buttonRegister);

            Log.Info(TAG, "Hello World");

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


            this.buttonRegister.Click += delegate
            {
                if (!registered)
                {
                    Log.Info(TAG, "Registering...");

                    //Call to register
                    GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);
                }
                else
                {
                    Log.Info(TAG, "Unregistering...");

                    //Call to unregister
                    GcmClient.UnRegister(this);
                }

                //Disable the button so multiple register requests don't happen
                RunOnUiThread(() => this.buttonRegister.Enabled = false);
            };
        }
        protected void GCMInit()
        {
            try
            {
                PackageInfo pInfo   = this.Activity.PackageManager.GetPackageInfo(this.Activity.PackageName, 0);
                var         shared  = this.Activity.GetSharedPreferences();
                var         version = shared.GetInt(GetString(Resource.String.shared_preferences_version), 0);
                var         temp    = shared.GetString(GetString(Resource.String.shared_preferences_gcm_handle), null);
                if (temp != null)
                {
                    GcmClient.UnRegister(Activity);
                }
                // If already registered for GCM, or if not connected to the internet proceed to login
                if (isNetworkAvailable())
                {
                    // Check for Google GCM
                    int errorCode = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this.Activity);
                    if (errorCode == ConnectionResult.Success)
                    {
                        GcmClient.Register(this.Activity, GcmBroadcastReceiver.SENDER_IDS);
                        Insight.Track("GcmClient.Register");
                    }
                    else
                    {
                        const int          PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
                        Android.App.Dialog dialog = GooglePlayServicesUtil.GetErrorDialog(errorCode, this.Activity, PLAY_SERVICES_RESOLUTION_REQUEST);
                        dialog.DismissEvent += delegate
                        {
                            this.Activity.Finish();
                        };

                        dialog.Show();
                    }
                }
            }
            catch (Exception e)
            {
                Insight.Report(e);
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Login);
            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);

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

            if (!GcmClient.IsRegisteredOnServer(this))
            {
                GcmClient.UnRegister(this);
            }
            GcmClient.Register(this, GcmBroadcastReceiver.SENDER_IDS);

            this.uriText  = FindViewById <EditText>(Resource.Id.ServiceUri);
            this.tagsText = FindViewById <EditText>(Resource.Id.ServiceTags);

            this.uriText.Text  = prefs.GetString(Keys.MobileServiceUri, null);
            this.tagsText.Text = prefs.GetString(Keys.TagExpression, null);

            FindViewById <Button>(Resource.Id.RunTests).Click += OnClickRunTests;
            FindViewById <Button>(Resource.Id.Login).Click    += OnClickLogin;

            string autoStart = ReadSettingFromIntentOrDefault(Keys.AutoStart, "false");

            if (autoStart != null && autoStart.ToLower() == "true")
            {
                TestConfig config = new TestConfig
                {
                    MobileServiceRuntimeUrl = ReadSettingFromIntentOrDefault(Keys.MobileServiceUri),
                    RuntimeVersion          = ReadSettingFromIntentOrDefault(Keys.RuntimeVersion),
                    TagExpression           = ReadSettingFromIntentOrDefault(Keys.TagExpression)
                };
                App.Harness.SetAutoConfig(config);
                RunTests();
            }
        }
        public override async Task UnRegisterForPush()
        {
            await base.UnRegisterForPush();

            GcmClient.UnRegister(Android.App.Application.Context);
        }
예제 #12
0
 public static void Unregister(Context Context)
 {
     GcmClient.UnRegister(Context);
 }