コード例 #1
0
ファイル: MainActivity.cs プロジェクト: kiyono-t/sdk-plugins
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            //Create the user interface in code
            var layout = new LinearLayout (this);
            layout.Orientation = Orientation.Vertical;

            // Get our button from the layout resource,
            // and attach an event to it
            var aButton = new Button (this);
            aButton.Text = "Start MobileAppTracker";
            aButton.Click += delegate {
                Log.Info (TAG, "MobileAppTracker constructor");

                mat = new MobileAppTracker (this, MAT_ADVERTISER_ID, MAT_CONVERSION_KEY);
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Toggle Debug Mode";
            aButton.Click += (sender, e) => {
                isDebug = !isDebug;

                Log.Info (TAG, "SetDebugMode = " + isDebug);

                mat.SetDebugMode(isDebug);
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Toggle Allow Duplicates";
            aButton.Click += (sender, e) => {
                isAllowDup = !isAllowDup;

                Log.Info (TAG, "SetAllowDuplicates = " + isAllowDup);

                mat.SetAllowDuplicates(isAllowDup);
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Test Install";
            aButton.Click += (sender, e) => {
                Log.Info (TAG, "TrackInstall");

                mat.TrackInstall();
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Test Update";
            aButton.Click += (sender, e) => {
                Log.Info (TAG, "TrackUpdate");

                mat.TrackUpdate();
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Test Event";
            aButton.Click += (sender, e) => {
                Log.Info (TAG, "Track Event");

                mat.TrackAction("event1");
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Test Event With Items";
            aButton.Click += (sender, e) => {
                Log.Info (TAG, "Track Event With Items");

                MATEventItem item1 = new MATEventItem("apple", 1, 0.99, 0.99);
                MATEventItem item2 = new MATEventItem("banana", "att1", "att2", "att3", "att4", "att5");

                List<MATEventItem> list = new List<MATEventItem>();
                list.Add(item1);
                list.Add(item2);

                mat.TrackAction("checkout", list);
            };
            layout.AddView (aButton);

            aButton = new Button (this);
            aButton.Text = "Test Setters";
            aButton.Click += (sender, e) => {
                Log.Info (TAG, "Test Setters");

                mat.PackageName = "com.abc.xyz";
                mat.SiteId = "12345";
                mat.UserId = "user123";
                mat.TRUSTeId = "truste123";
                mat.RefId = "ref123";
                mat.Latitude = 1.23;
                mat.Longitude = 12.3;
                mat.Altitude = 123.4;
                mat.AdvertiserId = "5432";
                mat.Gender = MobileAppTracker.GenderFemale;
                mat.CurrencyCode = "RUB";
                mat.Age = 23;

                mat.SetFacebookUserId("tempFacebookId");
                mat.SetGoogleUserId("tempGoogleId");
                mat.SetTwitterUserId("tempTwitterId");

                String matData = "\nPackageName = " + mat.PackageName
                                + "\nSiteId = " + mat.SiteId
                                + "\nUserId = " + mat.UserId
                                + "\nTRUSTeId = " + mat.TRUSTeId
                                + "\nRefId = " + mat.RefId
                                + "\nLatitude = " + mat.Latitude
                                + "\nLongitude = " + mat.Longitude
                                + "\nAltitude = " + mat.Altitude
                                + "\nAdvertiserId = " + mat.AdvertiserId
                                + "\nGender = " + mat.Gender
                                + "\nCurrencyCode = " + mat.CurrencyCode
                                + "\nAge = " + mat.Age;

                Log.Info (TAG, "MAT Data: " + matData);
            };
            layout.AddView (aButton);

            SetContentView (layout);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.

            btnStart.TouchUpInside += delegate {
                mat = MobileAppTracker.SharedManager;
                mat.InitTracker(MAT_ADVERTISER_ID, MAT_CONVERSION_KEY);
                mat.SetPackageName(MAT_PACKAGE_NAME);

                mat.Delegate = new TestMATDelegate();

                Console.WriteLine("MAT Tracker Started : adv id = {0}, conv key = {1}, package name = {2}", MAT_ADVERTISER_ID, MAT_CONVERSION_KEY, MAT_PACKAGE_NAME);
                Console.WriteLine("MAT SDK Data Params = " + mat.SdkDataParameters.ToString());
            };

            btnDebug.TouchUpInside += delegate {
                isDebugEnabled = !isDebugEnabled;
                mat.SetDebugMode(isDebugEnabled);
            };

            btnAllowDup.TouchUpInside += delegate {
                isAllowDuplicatesEnabled = !isAllowDuplicatesEnabled;
                mat.SetAllowDuplicates(isAllowDuplicatesEnabled);
            };

            btnPrintSDKParams.TouchUpInside += delegate {
                Console.WriteLine("MAT SDK Data Params = " + mat.SdkDataParameters.ToString());
            };

            btnInstall.TouchUpInside += delegate {
                mat.TrackInstall();
            };

            btnUpdate.TouchUpInside += delegate {
                mat.TrackUpdateWithReferenceId("ref11");
            };

            btnAction.TouchUpInside += delegate {
                mat.TrackAction("eventAction", false, "ref1", 1.99f, "GBP");
            };

            btnActionWithItems.TouchUpInside += delegate {

                MATEventItem item1 = MATEventItem.EventItemWithName("item1", 0.99f, 1, 0.99f, "1", "2", "3", "4", "5");
                MATEventItem item2 = MATEventItem.EventItemWithName("item2", 0.50f, 2, 1.0f);

                mat.TrackActionWithItems("eventItems", false, new MATEventItem[]{item1, item2}, "ref2", 0.89f, "CAD", 0);
            };

            btnActionWithReceipt.TouchUpInside += delegate {

                MATEventItem item1 = MATEventItem.EventItemWithName("item1", 0.99f, 1, 0.99f, "6", "7", "8", "9", "10");
                MATEventItem item2 = MATEventItem.EventItemWithName("item2", 0.50f, 2, 1.0f);

                mat.TrackActionWithReceipt("eventReceipt", false, new MATEventItem[]{item1, item2}, "ref3", 132.6f, "RUB", 0, GetSampleiTunesIAPReceipt());
            };

            btnSetterMethods.TouchUpInside += delegate {

                Console.WriteLine("MAT SDK Data Params before calling setters = " + mat.SdkDataParameters.ToString());

                mat.SetODIN1("tempODIN1");
                mat.SetOpenUDID("tempOpenUDID");
                mat.SetMACAddress("tempMACAddress");
                mat.SetTrusteTPID("tempTrusteTPID");
                mat.SetUserId("tempUserId");
                mat.SetUIID("tempUIID");
                mat.SetCurrencyCode("tempCurrencyCode");
                mat.SetGender(1);
                mat.SetLocation(1.1,2.2);
                mat.SetLocationWithAltitude(3.3,4.4,5.5);
                mat.SetUseCookieTracking(false);
                mat.SetUseCookieTracking(false);
                mat.SetAppAdTracking(true);
                mat.SetAge(23);
                mat.SetJailbroken(false);
                mat.SetMATAdvertiserId("tempMATAdvId");
                mat.SetMATConversionKey("tempMATConvKey");
                mat.SetAppleAdvertisingIdentifier(new NSUuid("12345678-1234-1234-1234-123456789012"));
                mat.SetAppleVendorIdentifier(new NSUuid("12345678-1234-1234-1234-123456789012"));

                Console.WriteLine("MAT SDK Data Params after calling setters = " + mat.SdkDataParameters.ToString());
            };
        }