Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ////////////////////
            ///proveri sve ovo

            base.OnCreate(savedInstanceState);
            Forms.Init(this, savedInstanceState);
            Platform.Init(this, savedInstanceState);
            Xamarin.FormsMaps.Init(this, savedInstanceState);
            LoadApplication(new App());

            if (!AppCenter.Configured)
            {
                Push.PushNotificationReceived += (sender, e) =>
                {
                    // Add the notification message and title to the message
                    var summary = $"Push notification received:" +
                                  $"\n\tNotification title: {e.Title}" +
                                  $"\n\tMessage: {e.Message}";

                    // If there is custom data associated with the notification,
                    // print the entries
                    if (e.CustomData != null)
                    {
                        summary += "\n\tCustom data:\n";
                        foreach (var key in e.CustomData.Keys)
                        {
                            summary += $"\t\t{key} : {e.CustomData[key]}\n";
                        }
                    }

                    // Send the notification summary to debug output

                    System.Diagnostics.Debug.WriteLine(summary);
                };
            }
            Push.EnableFirebaseAnalytics();

            AppCenter.Start("fe70b303-891e-4685-84a1-f3da83f76bb1", typeof(Analytics), typeof(Crashes), typeof(Push));


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


            CreateNotificationFromIntent(Intent);
        }
Exemplo n.º 2
0
        private void InitializeAppCenter()
        {
            // customize push
            Push.SetSenderId("{sender-id}");
            Push.EnableFirebaseAnalytics();
            Push.SetEnabledAsync(true);

            // set the log level
            AppCenter.LogLevel = LogLevel.Verbose;

            // start the service
            AppCenter.Start("{app-center-id}",
                            typeof(Analytics),
                            typeof(Crashes),
                            typeof(Distribute),
                            typeof(Push));
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            // Get the ViewPager and set it's PagerAdapter so that it can display items
            var viewPager = FindViewById(Resource.Id.viewpager) as ViewPager;

            viewPager.Adapter = new PagerAdapter(SupportFragmentManager, this);

            // Give the TabLayout the ViewPager
            var tabLayout = FindViewById(Resource.Id.tablayout) as TabLayout;

            tabLayout.SetupWithViewPager(viewPager);

            // App Center integration
            AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
            AppCenter.LogLevel = LogLevel.Verbose;
            AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
            AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

            // Set event handlers
            Crashes.SendingErrorReport      += SendingErrorReportHandler;
            Crashes.SentErrorReport         += SentErrorReportHandler;
            Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler;

            // Set callbacks
            Crashes.ShouldProcessErrorReport    = ShouldProcess;
            Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;

            Distribute.ReleaseAvailable = OnReleaseAvailable;
            AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);
            AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
            Distribute.SetInstallUrl("http://install.asgard-int.trafficmanager.net");
            Distribute.SetApiUrl("https://asgard-int.trafficmanager.net/api/v0.1");

            // Enable Firebase Analytics if set
            var enableAnalytics = Preferences.SharedPreferences.GetBoolean(Constants.FirebaseAnalyticsEnabledKey, false);

            if (enableAnalytics)
            {
                Push.EnableFirebaseAnalytics();
            }

            Push.PushNotificationReceived += PrintNotification;

            AppCenter.Start("bff0949b-7970-439d-9745-92cdc59b10fe", typeof(Analytics), typeof(Crashes),
                            typeof(Push), typeof(Distribute));

            AppCenter.IsEnabledAsync().ContinueWith(enabled =>
            {
                AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
            });
            AppCenter.GetInstallIdAsync().ContinueWith(installId =>
            {
                AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
            });
            Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
            {
                AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
            });
            Crashes.GetLastSessionCrashReportAsync().ContinueWith(report =>
            {
                AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Exception=" + report.Result?.Exception);
                AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Throwable=" + report.Result?.AndroidDetails?.Throwable);
            });
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // This should come before MobileCenter.Start() is called
            // This should come before MobileCenter.Start() is called
            Push.PushNotificationReceived += (sender, e) => {
                // Add the notification message and title to the message
                var summary = $"Push notification received:" +
                              $"\n\tNotification title: {e.Title}" +
                              $"\n\tMessage: {e.Message}";

                // If there is custom data associated with the notification,
                // print the entries
                if (e.CustomData != null)
                {
                    summary += "\n\tCustom data:\n";
                    foreach (var key in e.CustomData.Keys)
                    {
                        summary += $"\t\t{key} : {e.CustomData[key]}\n";
                    }
                }

                // Send the notification summary to debug output
                System.Diagnostics.Debug.WriteLine(summary);
            };
            Push.EnableFirebaseAnalytics();
            MobileCenter.Start("465bfc70-eb81-49c4-b7d2-f998d12e5be4",
                               typeof(Analytics), typeof(Crashes), typeof(Push));
            Analytics.TrackEvent("Click me");
            System.Guid?installId = MobileCenter.InstallId;
            // Set our view from the "main" layout resource
            // SetContentView (Resource.Layout.Main);
            SetContentView(Resource.Layout.Main);

            // 获取布局中的控件

            Button say = FindViewById <Button>(Resource.Id.sayHello);

            TextView show = FindViewById <TextView>(Resource.Id.showHello);

            // 绑定 Click 事件

            say.Click += (sender, e) =>

            {
                count++;

                show.Text = "Hello, Android";

                say.Text = $"You Clicked {count}";

                // Toast 通知

                Toast.MakeText(this, $"You Clicked {count}", ToastLength.Short).Show();
                if (count > 6)
                {
                    Crashes.Enabled = true;
                    //throw new System.Exception("error:click>5");
                    Crashes.GenerateTestCrash();
                }
            };
        }