/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class. /// </summary> /// <param name="policyFactory">An instance of IDeliveryPolicyFactory. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param> /// <param name="maConfig">Mobile Analytics Manager configuration. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/></param> /// <param name="clientContext">An instance of ClientContext. <see cref="Amazon.Runtime.Internal.ClientContext"/></param> /// <param name="credentials">An instance of Credentials. <see cref="Amazon.Runtime.AWSCredentials"/></param> /// <param name="regionEndPoint">Region endpoint. <see cref="Amazon.RegionEndpoint"/></param> /// <param name="maManager">Mobile Analytics Manager instance. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManager"/></param> public DeliveryClient(IDeliveryPolicyFactory policyFactory, MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint, MobileAnalyticsManager maManager) { _policyFactory = policyFactory; _deliveryPolicies = new List<IDeliveryPolicy>(); _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy()); _clientContext = clientContext; _appID = clientContext.AppID; _maConfig = maConfig; _eventStore = new SQLiteEventStore(maConfig); _maManager = maManager; if (null == credentials && null == regionEndPoint) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(); } else if (null == credentials) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(regionEndPoint); } else if (null == regionEndPoint) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials); } else { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint); } }
// Use this for initialization void Start() { UnityInitializer.AttachToGameObject(this.gameObject); _credentials = new CognitoAWSCredentials(IdentityPoolId, _CognitoIdentityRegion); analyticsManager = MobileAnalyticsManager.GetOrCreateInstance(appId, _credentials, _AnalyticsRegion); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button customEventButton = FindViewById<Button>(Resource.Id.button_custom_event); Button monetizationEventButton = FindViewById<Button>(Resource.Id.button_monetization_event); customEventButton.Click += delegate { CustomEvent customEvent = new CustomEvent("level_complete"); customEvent.AddAttribute("LevelName", "Level5"); customEvent.AddAttribute("Successful", "True"); customEvent.AddMetric("Score", 12345); customEvent.AddMetric("TimeInLevel", 64); _manager.RecordEvent(customEvent); }; monetizationEventButton.Click += delegate { MonetizationEvent monetizationEvent = new MonetizationEvent(); monetizationEvent.Quantity = 10.0; monetizationEvent.ItemPrice = 2.00; monetizationEvent.ProductId = "ProductId123"; monetizationEvent.ItemPriceFormatted = "$2.00"; monetizationEvent.Store = "Amazon"; monetizationEvent.TransactionId = "TransactionId123"; monetizationEvent.Currency = "USD"; _manager.RecordEvent(monetizationEvent); }; // customize your Mobile Analytics Manager Config MobileAnalyticsManagerConfig config = new MobileAnalyticsManagerConfig(); config.AllowUseDataNetwork = true; _manager = MobileAnalyticsManager.GetOrCreateInstance(APP_ID, new CognitoAWSCredentials(COGNITO_POOL_ID, COGNITO_REGION), RegionEndpoint.USEast1, config); }
// Use this for initialization void Start() { #if UNITY_EDITOR /// This is just to spoof the application to think that its running on iOS platform AmazonHookedPlatformInfo.Instance.Platform = "iPhoneOS"; AmazonHookedPlatformInfo.Instance.Model = "iPhone"; AmazonHookedPlatformInfo.Instance.Make = "Apple"; AmazonHookedPlatformInfo.Instance.Locale = "en_US"; AmazonHookedPlatformInfo.Instance.PlatformVersion = "8.1.2"; AmazonHookedPlatformInfo.Instance.Title = "YourApp"; AmazonHookedPlatformInfo.Instance.VersionName = "v1.0"; AmazonHookedPlatformInfo.Instance.VersionCode = "1.0"; AmazonHookedPlatformInfo.Instance.PackageName = "com.yourcompany.yourapp"; #endif _credentials = new CognitoAWSCredentials(IdentityPoolId, Amazon.RegionEndpoint.USEast1); analyticsManager = MobileAnalyticsManager.GetOrCreateInstance(_credentials, Amazon.RegionEndpoint.USEast1, appId); }
/// <summary> /// Gets the or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise /// creates new instance and returns it. /// </summary> /// <returns>Mobile Analytics Manager instance.</returns> /// <param name="credentials">AWS Credentials.</param> /// <param name="regionEndpoint">Region endpoint.</param> /// <param name="appId">Amazon Mobile Analytics Application ID.</param> public static MobileAnalyticsManager GetOrCreateInstance(AWSCredentials credential, RegionEndpoint regionEndpoint, string appId ) { if (credential == null) { throw new ArgumentNullException("credential"); } if (regionEndpoint == null) { throw new ArgumentNullException("regionEndpoint"); } if (string.IsNullOrEmpty(appId)) { throw new ArgumentNullException("appId"); } ClientContextConfig config = new ClientContextConfig(appId); return(MobileAnalyticsManager.GetOrCreateInstance(credential, regionEndpoint, config)); }
/// <summary> /// Gets the or create instance. /// </summary> /// <returns>The or create instance.</returns> /// <param name="clientContextConfig">Client context config.</param> /// <param name="regionEndpoint">Region endpoint.</param> /// <param name="credentials">Credentials.</param> private static MobileAnalyticsManager GetOrCreateInstanceHelper(string appId, AWSCredentials credential, RegionEndpoint regionEndpoint ) { MobileAnalyticsManager managerInstance = null; bool isNewInstance = false; lock (_lock) { if (_instanceDictionary.ContainsKey(appId)) { managerInstance = _instanceDictionary[appId]; } else { managerInstance = new MobileAnalyticsManager(appId, credential, regionEndpoint); _instanceDictionary[appId] = managerInstance; isNewInstance = true; } } if (isNewInstance) managerInstance.Session.Start(); BackgroundRunner.StartWork(); return managerInstance; }
private static MobileAnalyticsManager GetOrCreateInstanceHelper(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if BCL ValidateParameters(); #endif MobileAnalyticsManager managerInstance = null; bool isNewInstance = false; lock (_lock) { if (_instanceDictionary.TryGetValue(appID, out managerInstance)) { return managerInstance; } else { managerInstance = new MobileAnalyticsManager(appID, credentials, regionEndpoint, maConfig); _instanceDictionary[appID] = managerInstance; isNewInstance = true; } } if (isNewInstance) { managerInstance.Session.Start(); } return managerInstance; }
/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class. /// </summary> /// <param name="maConfig">Mobile Analytics Manager configuration. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/></param> /// <param name="clientContext">An instance of ClientContext. <see cref="Amazon.Runtime.Internal.ClientContext"/></param> /// <param name="credentials">An instance of Credentials. <see cref="Amazon.Runtime.AWSCredentials"/></param> /// <param name="regionEndPoint">Region endpoint. <see cref="Amazon.RegionEndpoint"/></param> /// <param name="maManager">Mobile Analytics Manager instance. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManager"/></param> public DeliveryClient(MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint, MobileAnalyticsManager maManager) : this(new DeliveryPolicyFactory(maConfig.AllowUseDataNetwork), maConfig, clientContext, credentials, regionEndPoint, maManager) { }