internal static void UpdatePluginVersion() { var ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string versionString = string.Format("Xamarin_{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); Console.WriteLine("Version is {0}", versionString); #if __IOS__ Localytics.SetOptions(Foundation.NSDictionary.FromObjectAndKey(new Foundation.NSString(versionString), new Foundation.NSString("plugin_library"))); #else Localytics.SetOption("plugin_library", versionString); #endif }
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); }; }
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); } } }; }