override public void OnCreate()
        {
            base.OnCreate();

                        #if DEBUG
            Localytics.LoggingEnabled = true;
                        #endif

            Localytics.AutoIntegrate(this);
            Localytics.SetLocationMonitoringEnabled(true);

            LocalyticsEvents.SubscribeToAll();

            // Analytics callbacks
            LocalyticsEvents.OnLocalyticsDidTagEvent      += LL_OnLocalyticsDidTagEvent;
            LocalyticsEvents.OnLocalyticsSessionWillOpen  += LL_OnLocalyticsSessionWillOpen;
            LocalyticsEvents.OnLocalyticsSessionDidOpen   += LL_OnLocalyticsSessionDidOpen;
            LocalyticsEvents.OnLocalyticsSessionWillClose += LL_OnLocalyticsSessionWillClose;

            // Messaging callbacks
            LocalyticsEvents.OnLocalyticsDidDismissInAppMessage           += LL_OnLocalyticsDidDismissInAppMessage;
            LocalyticsEvents.OnLocalyticsDidDisplayInAppMessage           += LL_OnLocalyticsDidDisplayInAppMessage;
            LocalyticsEvents.OnLocalyticsWillDismissInAppMessage          += LL_OnLocalyticsWillDismissInAppMessage;
            LocalyticsEvents.OnLocalyticsWillDisplayInAppMessage          += LL_OnLocalyticsWillDisplayInAppMessage;
            LocalyticsEvents.OnLocalyticsShouldShowPushNotification       += LL_OnLocalyticsShouldShowPushNotification;
            LocalyticsEvents.OnLocalyticsWillShowPushNotification         += LL_OnLocalyticsWillShowPushNotification;
            LocalyticsEvents.OnLocalyticsShouldShowPlacesPushNotification += LL_OnLocalyticsShouldShowPlacesPushNotification;
            LocalyticsEvents.OnLocalyticsWillShowPlacesPushNotification   += LL_OnLocalyticsWillShowPlacesPushNotification;

            // Location callbacks
            LocalyticsEvents.OnLocalyticsDidUpdateLocation           += LL_OnLocalyticsDidUpdateLocation;
            LocalyticsEvents.OnLocalyticsDidTriggerRegions           += LL_OnLocalyticsDidTriggerRegions;
            LocalyticsEvents.OnLocalyticsDidUpdateMonitoredGeofences += LL_OnLocalyticsDidUpdateMonitoredGeofences;
        }
예제 #2
0
        override public void OnCreate()
        {
            base.OnCreate();
            localyticsXamarin = LocalyticsXamarin.Shared.LocalyticsSDK.SharedInstance;

            Localytics.SetOption("ll_app_key", "f737ce58a68aea90b4c79fc-0bc951b0-b42b-11e3-429f-00a426b17dd8");
#if DEBUG
            localyticsXamarin.LoggingEnabled = true;
#endif

            Localytics.AutoIntegrate(this);
            Localytics.SetLocationMonitoringEnabled(true);

            //// Analytics callbacks
            LocalyticsSDK.LocalyticsDidTagEvent      += LL_OnLocalyticsDidTagEvent;
            LocalyticsSDK.LocalyticsSessionWillOpen  += LL_OnLocalyticsSessionWillOpen;
            LocalyticsSDK.LocalyticsSessionDidOpen   += LL_OnLocalyticsSessionDidOpen;
            LocalyticsSDK.LocalyticsSessionWillClose += LL_OnLocalyticsSessionWillClose;

            //// Messaging callbacks
            LocalyticsSDK.InAppDidDismissEvent     += LL_OnLocalyticsDidDismissInAppMessage;
            LocalyticsSDK.InAppDidDisplayEvent     += LL_OnLocalyticsDidDisplayInAppMessage;
            LocalyticsSDK.InAppWillDismissEvent    += LL_OnLocalyticsWillDismissInAppMessage;
            LocalyticsSDK.InAppWillDisplayDelegate += LL_OnLocalyticsWillDisplayInAppMessage;

            Localytics.ShouldShowPushNotification             += LL_OnLocalyticsShouldShowPushNotification;
            LocalyticsSDK.PlacesShouldDisplayCampaignDelegate += LL_OnLocalyticsShouldShowPlacesPushNotification;

            Localytics.WillShowPushNotification       += LL_OnLocalyticsWillShowPushNotification;
            Localytics.WillShowPlacesPushNotification += LL_OnLocalyticsWillShowPlacesPushNotification;

            //// Location callbacks
            LocalyticsSDK.LocalyticsDidUpdateLocation += LL_OnLocalyticsDidUpdateLocation;
            LocalyticsSDK.LocalyticsDidTriggerRegions += (sender, e) => {
                Console.WriteLine("XamarinEvent LocalyticsDidTriggerRegions " + e);
            };
            LocalyticsSDK.LocalyticsDidUpdateMonitoredGeofences += LL_OnLocalyticsDidUpdateMonitoredGeofences;

            Localytics.ShouldPromptForLocationPermission += (arg) => {
                Console.WriteLine("XamarinEvent ShouldPromptForLocationPermission " + arg);
                return(true);
            };

            Localytics.DeeplinkToSettings += (i, c) =>
            {
                Console.WriteLine("XamarinEvent ShouldPromptForLocationPermission " + i + c);
                return(true);
            };
        }
예제 #3
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
 {
     switch (requestCode)
     {
     case RequestLocationId:
     {
         if (grantResults[0] == Permission.Granted)
         {
             Localytics.SetLocationMonitoringEnabled(true);
         }
         else
         {
             Toast.MakeText(this, "Must accept location permission to use Places", ToastLength.Long).Show();
         }
     }
     break;
     }
 }
예제 #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            LocalyticsAutoIntegrateApplication.localyticsXamarin.CustomerId = "ms_test_user";

            // Register Push
            Localytics.RegisterPush();                  //"YOUR_GCM_PROJECT_NUMBER");
            Localytics.SetOption("session_timeout", 1); // Shorten for testing purpose only

            Button tagEventButton = FindViewById <Button>(Resource.Id.tagEventButton);

            tagEventButton.Click += delegate
            {
                LocalyticsAutoIntegrateApplication.localyticsXamarin.TagEvent("MessagingSample Click");
                Localytics.Upload();
            };

            Button showRegistrationIdButton = FindViewById <Button>(Resource.Id.showRegistrationId);

            showRegistrationIdButton.Click += delegate
            {
                // Blocking Getters may need to be threaded out
                ThreadPool.QueueUserWorkItem(delegate
                {
                    TextView pushText = FindViewById <TextView>(Resource.Id.pushText);
                    string pushRegId  = Localytics.PushRegistrationId;

                    // Update UI back on UI Thread
                    RunOnUiThread(() =>
                    {
                        pushText.Text = pushRegId;
                    });
                });
            };

            Button openInboxButton = FindViewById <Button>(Resource.Id.openInbox);

            openInboxButton.Click += delegate
            {
                StartActivity(typeof(InboxActivity));
            };

            Button startPlacesButton = FindViewById <Button>(Resource.Id.startPlaces);

            startPlacesButton.Click += delegate
            {
                if ((int)Build.VERSION.SdkInt < 23)
                {
                    Localytics.SetLocationMonitoringEnabled(true);
                }
                else
                {
                    const string permission = Manifest.Permission.AccessFineLocation;
                    if (ActivityCompat.CheckSelfPermission(this, permission) == (int)Permission.Granted)
                    {
                        Localytics.SetLocationMonitoringEnabled(true);
                    }
                    else
                    {
                        ActivityCompat.RequestPermissions(this, PermissionsLocation, RequestLocationId);
                    }
                }
            };
        }