Exemplo n.º 1
0
        private void OnIdentityButton_Click(object sender, RoutedEventArgs e)
        {
            string content         = ((Button)sender).Content as string;
            var    customerId      = (FindName("customerIdInput") as TextBox).Text;
            var    email           = (FindName("emailInput") as TextBox).Text;
            var    identityRequest = IdentityApiRequest.EmptyUser()
                                     .CustomerId(customerId)
                                     .Email(email)
                                     .Build();
            Task <IdentityApiResult> task = null;

            switch (content)
            {
            case "Identify":
                task = MParticle.Instance.Identity.IdentifyAsync(identityRequest);
                break;

            case "Login":
                task = MParticle.Instance.Identity.LoginAsync(identityRequest);
                break;

            case "Logout":
                task = MParticle.Instance.Identity.LogoutAsync(identityRequest);
                break;

            case "Modify":
                task = MParticle.Instance.Identity.CurrentUser?.ModifyAsync(identityRequest);
                break;
            }

            App.HandleIdentityTaskAsync(task);
        }
Exemplo n.º 2
0
        protected override void OnLaunched(LaunchActivatedEventArgs launchArgs)
        {
            // Create an Identity Request:
            // The SDK will automatically make an Identify() request during initialization,
            // if you know identities of the current-user, you should provide them.
            // Otherwise, the SDK will use the Identities of the most recent user.
            var identifyRequest = IdentityApiRequest.EmptyUser()
                                  .CustomerId("foo")
                                  .Email("bar")
                                  .Build();

            // Create an MParticleOptions object:
            // You must at least provide an mParticle workspace key and secret
            MParticleOptions options =
                MParticleOptions.Builder(apiKey: "REPLACE ME", apiSecret: "REPLACE ME")
                .IdentifyRequest(identifyRequest)
                .LaunchArgs(launchArgs)
                .Logger(new ExampleConsoleLogger())
                .Build();

            // Initialize the mParticle SDK:
            // You must do this prior to calling MParticle.Instance
            var task = MParticle.StartAsync(options);

            HandleIdentityTaskAsync(task);

            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            if (launchArgs.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(MainPage), launchArgs.Arguments);
                }
                Window.Current.Activate();
            }
        }