Exemplo n.º 1
0
        //This is the main entry point of the application.
        static void Main(string[] args)
        {
            try
            {
                UIApplication.Main(args, null, "AppDelegate");
            }
            catch (Exception e)
            {
                var ex = e.GetBaseException();
                Console.WriteLine("**SPORT MAIN EXCEPTION**\n\n" + ex);
                InsightsManager.Report(ex, Xamarin.Insights.Severity.Critical);
                throw;
            }

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                try
                {
                    var ex = ((Exception)e.ExceptionObject).GetBaseException();
                    Console.WriteLine("**SPORT UNHANDLED EXCEPTION**\n\n" + ex);
                    InsightsManager.Report(ex, Xamarin.Insights.Severity.Critical);
                }
                catch
                {
                }
            };
        }
        public override UIViewController PopViewController(bool animated)
        {
            try
            {
                var obj = Element.GetType().InvokeMember("StackCopy", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, Element, null);
                if (obj != null)
                {
                    var pages = obj as Stack <Page>;
                    if (pages != null && pages.Count >= 2)
                    {
                        var copy = new Page[pages.Count];
                        pages.CopyTo(copy, 0);

                        var prev = copy[1];
                        ChangeTheme(prev);
                    }
                }
            }
            catch (Exception e)
            {
                InsightsManager.Report(e);
            }

            return(base.PopViewController(animated));
        }
Exemplo n.º 3
0
        public async Task <MobileServiceUser> DisplayWebView()
        {
            try
            {
                return(await AzureService.Instance.Client.LoginAsync(Forms.Context, MobileServiceAuthenticationProvider.Google));
            }
            catch (Exception e)
            {
                InsightsManager.Report(e);
            }

            return(null);
        }
Exemplo n.º 4
0
 protected override void OnRegistered(Context context, string registrationId)
 {
     try
     {
         App.CurrentAthlete.DeviceToken = registrationId;
         MessagingCenter.Send <App>(App.Current, Messages.RegisteredForRemoteNotifications);
     }
     catch (Exception e)
     {
         InsightsManager.Report(e);
         Debug.WriteLine(e);
     }
 }
Exemplo n.º 5
0
 public void RegisterForPushNotifications()
 {
     try
     {
         GcmClient.CheckDevice(Forms.Context);
         GcmClient.CheckManifest(Forms.Context);
         GcmClient.Register(Forms.Context, GcmBroadcastReceiver.SENDER_IDS);
     }
     catch (Exception e)
     {
         InsightsManager.Report(e);
         Debug.WriteLine(e);
     }
 }
Exemplo n.º 6
0
        protected override void OnCreate(global::Android.OS.Bundle bundle)
        {
            if (InsightsManager.IsEnabled)
            {
                Xamarin.Insights.Initialize(Keys.InsightsApiKey, this);
            }

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                try
                {
                    var ex = ((Exception)e.ExceptionObject).GetBaseException();
                    Console.WriteLine("**SPORT MAIN ACTIVITY EXCEPTION**\n\n" + ex);
                    InsightsManager.Report(ex, Xamarin.Insights.Severity.Critical);
                }
                catch
                {
                }
            };

            try
            {
                base.OnCreate(bundle);
                Window.SetSoftInputMode(SoftInput.AdjustPan);
                Xamarin.Forms.Forms.Init(this, bundle);
                ImageCircleRenderer.Init();

                //We're using the value of the StyleId as the content description for use w/ Xamarin UITest / XTC
                Xamarin.Forms.Forms.ViewInitialized += (sender, e) =>
                {
                    if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                    {
                        e.NativeView.ContentDescription = e.View.StyleId;
                    }
                };

                LoadApplication(new App());

                var color = new ColorDrawable(Color.Transparent);
                ActionBar.SetIcon(color);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
Exemplo n.º 7
0
        public async Task <MobileServiceUser> DisplayWebView()
        {
            try
            {
                var window = UIKit.UIApplication.SharedApplication.KeyWindow;
                var root   = window.RootViewController;
                if (root != null)
                {
                    var current = root;
                    while (current.PresentedViewController != null)
                    {
                        current = current.PresentedViewController;
                    }

                    return(await AzureService.Instance.Client.LoginAsync(current, MobileServiceAuthenticationProvider.Google));
                }
            }
            catch (Exception e)
            {
                InsightsManager.Report(e);
            }

            return(null);
        }
Exemplo n.º 8
0
        internal static bool HandlePushNotification(Context context, Intent intent)
        {
            string message;

            if (!intent.Extras.ContainsKey("message"))
            {
                return(false);
            }

            message = intent.Extras.Get("message").ToString();
            var title = intent.Extras.Get("title").ToString();

            var activityIntent = new Intent(context, typeof(MainActivity));
            var payloadValue   = GetPayload(intent);

            activityIntent.PutExtra("payload", payloadValue);
            activityIntent.SetFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(context, 0, activityIntent, PendingIntentFlags.UpdateCurrent);

            var n = new Notification.Builder(context);

            n.SetSmallIcon(Resource.Drawable.ic_successstatus);
            n.SetLights(global::Android.Graphics.Color.Blue, 300, 1000);
            n.SetContentIntent(pendingIntent);
            n.SetContentTitle(title);
            n.SetTicker(message);
            n.SetLargeIcon(global::Android.Graphics.BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.icon));
            n.SetSmallIcon(Resource.Drawable.ic_trophy_white);
            n.SetContentText(message);
            n.SetVibrate(new long[] {
                200,
                200,
                100,
            });

            var nm = NotificationManager.FromContext(context);

            nm.Notify(0, n.Build());

            if (MainActivity.IsRunning)
            {
                try
                {
                    message.ToToast();
                    var payload = GetPayload(intent);
                    var pl      = JsonConvert.DeserializeObject <NotificationPayload>(payload);

                    if (payloadValue != null)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            MessagingCenter.Send <App, NotificationPayload>(App.Current, Messages.IncomingPayloadReceivedInternal, pl);
                        });
                    }
                }
                catch (Exception e)
                {
                    InsightsManager.Report(e, Insights.Severity.Error);
                }
            }

            return(true);
        }