internal static AndroidBinding.MParticleOptions ConvertToMpOptions(MParticleOptions options) { var builder = AndroidBinding.MParticleOptions.InvokeBuilder(Application.Context); builder.AndroidIdDisabled(options.IdDisabled); if (options.AttributionListener != null) { builder.AttributionListener(ConvertToMpAttributionListener(options.AttributionListener)); } builder.InstallType(ConvertToMpInstallType(options.InstallType)); builder.Environment(ConvertToMpEnvironment(options.Environment)); builder.Credentials(options.ApiKey, options.ApiSecret); if (options.IdentifyRequest != null) { builder.Identify(ConvertToMpIdentityRequest(options.IdentifyRequest)); } if (options.LocationTracking != null) { if (options.LocationTracking.Enabled) { builder.LocationTrackingEnabled(options.LocationTracking.Provider, options.LocationTracking.MinTime, options.LocationTracking.MinDistance); } else { builder.LocationTrackingDisabled(); } } if (options.PushRegistration != null && options.PushRegistration.AndroidSenderId != null && options.PushRegistration.AndroidInstanceId != null) { builder.PushRegistration(options.PushRegistration.AndroidInstanceId, options.PushRegistration.AndroidSenderId); } return(builder.Build()); }
public void Initialize(MParticleOptions options) { if (Application.platform == RuntimePlatform.OSXEditor) { return; } if (options == null) { options = new MParticleOptions(); } if (options.IdentityStateListener != null) { Identity.AddIdentityStateListener(options.IdentityStateListener); } String optionsJson; if (options.IdentifyRequest != null && options.IdentifyRequest.UserAliasHandler != null) { optionsJson = toUtils.SerializeDictionary(new MParticleOptionsDto(options, (Identity as IdentityApiImpl).addUserAliasHandler(options.IdentifyRequest.UserAliasHandler))); } else { optionsJson = toUtils.SerializeDictionary(new MParticleOptionsDto(options)); } _Initialize(optionsJson); }
internal AndroidJavaObject ConvertToMpOptions(MParticleOptions options, object context) { var nativeMpOptions = new AndroidJavaClass("com.mparticle.MParticleOptions").CallStatic <AndroidJavaObject>("builder", new object[] { context }); nativeMpOptions.Call <AndroidJavaObject>("credentials", new object[] { options.ApiKey, options.ApiSecret }); if (options.InstallType.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("installType", new object[] { ConvertToMpInstallType(options.InstallType.Value) }); } if (options.Environment.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("environment", new object[] { ConvertToMpEnvironment(options.Environment.Value) }); } if (options.IdentifyRequest != null) { nativeMpOptions.Call <AndroidJavaObject>("identify", new object[] { ConvertToMpIdentifyRequest(options.IdentifyRequest) }); } if (options.DevicePerformanceMetricsDisabled.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("devicePerformanceMetricsDisabled", new object[] { options.DevicePerformanceMetricsDisabled }); } if (options.UploadInterval.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("uploadInterval", new object[] { options.UploadInterval }); } if (options.SessionTimeout.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("sessionTimeout", new object[] { options.SessionTimeout }); } if (options.UnCaughtExceptionLogging.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("enableUncaughtExceptionLogging", new object[] { options.UnCaughtExceptionLogging }); } if (options.LogLevel.HasValue) { nativeMpOptions.Call <AndroidJavaObject>("logLevel", new object[] { ConvertToMpLogLevel(options.LogLevel.Value) }); } if (options.LocationTracking != null) { if (options.LocationTracking.Enabled) { nativeMpOptions.Call <AndroidJavaObject>("locationTrackingEnabled", new object[] { options.LocationTracking.Provider, options.LocationTracking.MinTime, options.LocationTracking.MinDistance }); } else { nativeMpOptions.Call <AndroidJavaObject>("locationTrackingDisabled", new object[] { }); } } if (options.PushRegistration != null && options.PushRegistration.AndroidInstanceId != null && options.PushRegistration.AndroidSenderId != null) { nativeMpOptions.Call <AndroidJavaObject>("pushRegistration", new object[] { options.PushRegistration.AndroidInstanceId, options.PushRegistration.AndroidSenderId }); } return(nativeMpOptions.Call <AndroidJavaObject>("build")); }
public void Initialize(MParticleOptions options) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); new AndroidJavaClass("com.mparticle.MParticle").CallStatic("start", toUtils.ConvertToMpOptions(options, jc.GetStatic <AndroidJavaObject>("currentActivity"))); mp = new AndroidJavaClass("com.mparticle.MParticle"). CallStatic <AndroidJavaObject>("getInstance"); }
public async Task TestMParticleStartCorrectOptionsAsync() { await ExecuteOnUIThread(async() => { await MParticle.StartAsync ( MParticleOptions.Builder("foo", "bar").Build() ); }); Assert.IsNotNull(MParticle.Instance); }
internal static iOSBinding.MParticleOptions ConvertToMpOptions(MParticleOptions options) { return(new iOSBinding.MParticleOptions() { InstallType = ConvertToMpInstallType(options.InstallType), Environment = ConvertToMpEnvironment(options.Environment), ApiKey = options.ApiKey, ApiSecret = options.ApiSecret, IdentifyRequest = ConvertToMpIdentityRequest(options.IdentifyRequest), OnAttributionCompleted = ConvertToMpAttributionListener(options.AttributionListener), OnIdentifyComplete = ConvertToMpIdentifyCompleteListener(options.IdentityStateListener) }); }
internal MParticleOptionsDto(MParticleOptions options, String userAliasUuid = null) { Add(ApiKey, options.ApiKey); Add(ApiSecret, options.ApiSecret); if (options.InstallType.HasValue) { Add(InstallType, ((int)options.InstallType.Value).ToString()); } if (options.Environment.HasValue) { Add(Environment, ((int)options.Environment.Value).ToString()); } if (options.IdentifyRequest != null) { Add(IdentifyRequest, new IdentityApiRequestDto(options.IdentifyRequest, null, userAliasUuid)); } if (options.DevicePerformanceMetricsDisabled.HasValue) { Add(DevicePerformanceMetricsDisabled, options.DevicePerformanceMetricsDisabled.Value.ToString()); } if (options.IdDisabled.HasValue) { Add(IdDisabled, options.IdDisabled.Value.ToString()); } if (options.UploadInterval.HasValue) { Add(UploadInterval, options.UploadInterval.Value.ToString()); } if (options.SessionTimeout.HasValue) { Add(SessionTimeout, options.SessionTimeout.Value.ToString()); } if (options.UnCaughtExceptionLogging.HasValue) { Add(UnCaughtExceptionLogging, options.UnCaughtExceptionLogging.Value.ToString()); } if (options.LogLevel.HasValue) { Add(LogLevel, ((int)options.LogLevel.Value).ToString()); } if (options.LocationTracking != null) { Add(LocationTracking, new LocationTrackingDto(options.LocationTracking)); } if (options.PushRegistration != null) { Add(PushRegistration, new PushRegistrationDto(options.PushRegistration)); } }
public async Task TestLogEventAsync() { await ExecuteOnUIThread(async() => { await MParticle.StartAsync ( MParticleOptions.Builder("foo", "bar").Build() ); }); CustomEvent customEvent = CustomEvent.Builder("foo").Build(); MParticle.Instance.LogEvent(customEvent); }
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(); } }
internal static iOSBinding.MParticleOptions ConvertToMpOptions(MParticleOptions options) { var mpOptions = new iOSBinding.MParticleOptions(); mpOptions.InstallType = ConvertToMpInstallType(options.InstallType); mpOptions.Environment = ConvertToMpEnvironment(options.Environment); mpOptions.ApiKey = options.ApiKey; mpOptions.ApiSecret = options.ApiSecret; if (options.IdentifyRequest != null) { mpOptions.IdentifyRequest = ConvertToMpIdentityRequest(options.IdentifyRequest); } if (options.AttributionListener != null) { mpOptions.OnAttributionCompleted = ConvertToMpAttributionListener(options.AttributionListener); } if (options.IdentityStateListener != null) { mpOptions.OnIdentifyComplete = ConvertToMpIdentifyCompleteListener(options.IdentityStateListener); } return(mpOptions); }