예제 #1
0
        // Initialize the default starting properties. Should only be called once by MobileAppTracker.
        public Parameters(string advId, string advKey, byte[] bytes)
        {
            this.culture = new CultureInfo("en-US");

            this.advertiserId = advId;
            this.advertiserKey = advKey;

            this.localSettings = ApplicationData.Current.LocalSettings;

            this.urlEncrypter = new Encryption(advKey, IV);

            this.matResponse = null;

            // Default values
            this.AllowDuplicates = false;
            this.DebugMode = false;
            this.ExistingUser = false;
            this.AppAdTracking = true;
            this.Gender = MATGender.NONE;

            this.WindowsAid = AdvertisingManager.AdvertisingId;

            // Get app name asynchronously from appxmanifest
            this.AppName = GetAppName();

            var version = Package.Current.Id.Version;
            this.AppVersion = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

            this.PackageName = Package.Current.Id.Name;

            // Get device info
            EasClientDeviceInformation info = new EasClientDeviceInformation();

            this.DeviceBrand = info.SystemManufacturer.ToString();
            this.DeviceModel = info.SystemProductName.ToString();
            this.DeviceType = info.OperatingSystem.ToString(); //Windows or WindowsPhone

            // Get ASHWID
            this.ASHWID = BitConverter.ToString(bytes);

            // Check if we can restore existing MAT ID or should generate new one
            if (localSettings.Values.ContainsKey(SETTINGS_MATID_KEY))
            {
                this.MatId = (string)localSettings.Values[SETTINGS_MATID_KEY];
            }
            else // Don't have MAT ID, generate new guid
            {
                this.MatId = System.Guid.NewGuid().ToString();
                SaveLocalSetting(SETTINGS_MATID_KEY, this.MatId);
            }
        }
예제 #2
0
        //Initialize the default starting properties. Should only be called once by MobileAppTracker.
        internal Parameters(string advId, string advKey)
        {
            // Initialize Parameters
            this.advertiserId = advId;
            this.advertiserKey = advKey;

            matResponse = null;

            this.AllowDuplicates = false;
            this.DebugMode = false;
            this.ExistingUser = false;
            this.AppAdTracking = true;
            this.Gender = MATGender.NONE;

            // Get Windows AID through Reflection if app on WP8.1 device
            var type = Type.GetType("Windows.System.UserProfile.AdvertisingManager, Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime");
            this.WindowsAid = type != null ? (string)type.GetProperty("AdvertisingId").GetValue(null, null) : null;

            XElement app = XDocument.Load("WMAppManifest.xml").Root.Element("App");
            this.AppName = GetValue(app, "Title");
            this.AppVersion = GetValue(app, "Version");

            string productId = GetValue(app, "ProductID");
            this.PackageName = Regex.Match(productId, "(?<={).*(?=})").Value;

            byte[] deviceUniqueId = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
            this.DeviceUniqueId = Convert.ToBase64String(deviceUniqueId);
            this.DeviceBrand = DeviceStatus.DeviceManufacturer;
            this.DeviceModel = DeviceStatus.DeviceName;
            this.DeviceCarrier = DeviceNetworkInformation.CellularMobileOperator;

            Version version = Environment.OSVersion.Version;
            this.OSVersion = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
            this.DeviceScreenSize = GetScreenRes();

            // Check if we can restore existing MAT ID or should generate new one
            if (IsolatedStorageSettings.ApplicationSettings.Contains(SETTINGS_MATID_KEY))
            {
                this.MatId = (string)IsolatedStorageSettings.ApplicationSettings[SETTINGS_MATID_KEY];
            }
            else // Don't have MAT ID, generate new guid
            {
                this.MatId = System.Guid.NewGuid().ToString();
                SaveLocalSetting(SETTINGS_MATID_KEY, this.MatId);
            }
        }
예제 #3
0
 internal void SetMATResponse(MATResponse response)
 {
     this.matResponse = response;
 }
 public void SetMATResponse(MATResponse response)
 {
     parameters.SetMATResponse(response);
 }
예제 #5
0
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 /*---------------------Windows Specific Features-------------------*/
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
 #if UNITY_METRO
 /// <para>
 /// Sets the MAT response.
 /// Does nothing if not a Windows device.
 /// </para>
 /// <param name="matResponse">MAT response</param>
 public static void SetMATResponse(MATResponse matResponse)
 {
     if (!Application.isEditor) {
         MobileAppTracker.Instance.SetMATResponse(matResponse);
     }
 }
예제 #6
0
 internal void SetMATResponse(MATResponse response)
 {
     this.matResponse = response;
 }
예제 #7
0
 public void SetMATResponse(MATResponse response)
 {
     parameters.SetMATResponse(response);
 }
예제 #8
0
        public MobileAppTracker(string advId, string advKey)
        {
            this.culture = new CultureInfo("en-US");

            this.advertiserId  = advId;
            this.advertiserKey = advKey;

            this.localSettings = ApplicationData.Current.LocalSettings;
            this.syncLock      = new object();

            this.urlEncrypter = new Encryption(advKey, IV);

            this.matResponse = null;

            // Default values
            this.AllowDuplicates = false;
            this.DebugMode       = false;
            this.ExistingUser    = false;
            this.AppAdTracking   = true;
            this.Gender          = MATGender.NONE;

            var version = Package.Current.Id.Version;

            this.AppVersion = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

            this.PackageName = Package.Current.Id.Name;

            // Get ASHWID
            var hardwareId = HardwareIdentification.GetPackageSpecificToken(null).Id;
            var dataReader = DataReader.FromBuffer(hardwareId);

            byte[] bytes = new byte[hardwareId.Length];
            dataReader.ReadBytes(bytes);
            this.ASHWID = BitConverter.ToString(bytes);

            // Check if we can restore existing MAT ID or should generate new one
            if (localSettings.Values.ContainsKey(SETTINGS_MATID_KEY))
            {
                this.MatId = (string)localSettings.Values[SETTINGS_MATID_KEY];
            }
            else // Don't have MAT ID, generate new guid
            {
                this.MatId = System.Guid.NewGuid().ToString();
                SaveLocalSetting(SETTINGS_MATID_KEY, this.MatId);
            }

            // Handles the OnNetworkStatusChange event
            NetworkStatusChangedEventHandler networkStatusCallback = null;

            // Indicates if the connection profile is registered for network status change events. Set the default value to FALSE.
            bool registeredNetworkStatusNotif = false;

            networkStatusCallback = new NetworkStatusChangedEventHandler(OnNetworkStatusChange);

            // Register for network status change notifications
            if (!registeredNetworkStatusNotif)
            {
                NetworkInformation.NetworkStatusChanged += networkStatusCallback;
                registeredNetworkStatusNotif             = true;
            }

            // Check for internet connectivity and send queued requests
            ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile();

            if (profile != null && profile.GetNetworkConnectivityLevel() >= NetworkConnectivityLevel.InternetAccess)
            {
                DumpQueue();
            }
        }
예제 #9
0
 public void SetMATResponse(MATResponse response)
 {
     this.matResponse = response;
 }
예제 #10
0
        public MobileAppTracker(string advId, string advKey)
        {
            this.culture = new CultureInfo("en-US");

            this.advertiserId = advId;
            this.advertiserKey = advKey;

            this.localSettings = ApplicationData.Current.LocalSettings;
            this.syncLock = new object();

            this.urlEncrypter = new Encryption(advKey, IV);

            this.matResponse = null;

            // Default values
            this.AllowDuplicates = false;
            this.DebugMode = false;
            this.ExistingUser = false;
            this.AppAdTracking = true;
            this.Gender = MATGender.NONE;

            var version = Package.Current.Id.Version;
            this.AppVersion = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

            this.PackageName = Package.Current.Id.Name;

            // Get ASHWID
            var hardwareId = HardwareIdentification.GetPackageSpecificToken(null).Id;
            var dataReader = DataReader.FromBuffer(hardwareId);
            byte[] bytes = new byte[hardwareId.Length];
            dataReader.ReadBytes(bytes);
            this.ASHWID = BitConverter.ToString(bytes);

            // Check if we can restore existing MAT ID or should generate new one
            if (localSettings.Values.ContainsKey(SETTINGS_MATID_KEY))
            {
                this.MatId = (string)localSettings.Values[SETTINGS_MATID_KEY];
            }
            else // Don't have MAT ID, generate new guid
            {
                this.MatId = System.Guid.NewGuid().ToString();
                SaveLocalSetting(SETTINGS_MATID_KEY, this.MatId);
            }

            // Handles the OnNetworkStatusChange event
            NetworkStatusChangedEventHandler networkStatusCallback = null;

            // Indicates if the connection profile is registered for network status change events. Set the default value to FALSE.
            bool registeredNetworkStatusNotif = false;

            networkStatusCallback = new NetworkStatusChangedEventHandler(OnNetworkStatusChange);

            // Register for network status change notifications
            if (!registeredNetworkStatusNotif)
            {
                NetworkInformation.NetworkStatusChanged += networkStatusCallback;
                registeredNetworkStatusNotif = true;
            }

            // Check for internet connectivity and send queued requests
            ConnectionProfile profile = NetworkInformation.GetInternetConnectionProfile();
            if (profile != null && profile.GetNetworkConnectivityLevel() >= NetworkConnectivityLevel.InternetAccess)
                DumpQueue();
        }
예제 #11
0
 public void SetMATResponse(MATResponse response)
 {
     this.matResponse = response;
 }
예제 #12
0
        // Initialize the default starting properties. Should only be called once by MobileAppTracker.
        public MATParameters(string advId, string advKey, byte[] bytes)
        {
            this.culture = new CultureInfo("en-US");

            this.advertiserId = advId;
            this.advertiserKey = advKey;

            this.localSettings = ApplicationData.Current.LocalSettings;

            this.urlEncrypter = new MATEncryption(advKey, MATConstants.IV);

            this.matResponse = null;

            // Default values
            this.AllowDuplicates = false;
            this.DebugMode = false;
            this.ExistingUser = false;
            this.AppAdTracking = true;
            this.Gender = MATGender.NONE;

            this.WindowsAid = AdvertisingManager.AdvertisingId;

            // Get app name asynchronously from appxmanifest
            this.AppName = GetAppName();

            var version = Package.Current.Id.Version;
            this.AppVersion = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);

            // Use local package name by default
            this.PackageName = Package.Current.Id.Name;
            try
            {
                // If there's a store app id, use it
                if (CurrentApp.AppId != Guid.Empty)
                {
                    this.PackageName = CurrentApp.AppId.ToString();
                }
            }
            catch
            {
            }

            // Get device info
            EasClientDeviceInformation info = new EasClientDeviceInformation();

            this.DeviceBrand = info.SystemManufacturer.ToString();
            this.DeviceModel = info.SystemProductName.ToString();
            this.DeviceType = info.OperatingSystem.ToString(); //Windows or WindowsPhone

            // Get ASHWID
            this.ASHWID = BitConverter.ToString(bytes);

            // Check if we can restore existing MAT ID or should generate new one
            if (localSettings.Values.ContainsKey(MATConstants.SETTINGS_MATID_KEY))
            {
                this.MatId = (string)localSettings.Values[MATConstants.SETTINGS_MATID_KEY];
            }
            else // Don't have MAT ID, generate new guid
            {
                this.MatId = System.Guid.NewGuid().ToString();
                SaveLocalSetting(MATConstants.SETTINGS_MATID_KEY, this.MatId);
            }

            // Get saved values from LocalSettings
            if (GetLocalSetting(MATConstants.SETTINGS_PHONENUMBER_KEY) != null) {
                this.PhoneNumber = (string)GetLocalSetting(MATConstants.SETTINGS_PHONENUMBER_KEY);
                this.PhoneNumberMd5 = MATEncryption.Md5(this.PhoneNumber);
                this.PhoneNumberSha1 = MATEncryption.Sha1(this.PhoneNumber);
                this.PhoneNumberSha256 = MATEncryption.Sha256(this.PhoneNumber);
            }

            if (GetLocalSetting(MATConstants.SETTINGS_USEREMAIL_KEY) != null)
            {
                this.UserEmail = (string)GetLocalSetting(MATConstants.SETTINGS_USEREMAIL_KEY);
                this.UserEmailMd5 = MATEncryption.Md5(this.UserEmail);
                this.UserEmailSha1 = MATEncryption.Sha1(this.UserEmail);
                this.UserEmailSha256 = MATEncryption.Sha256(this.UserEmail);
            }

            this.UserId = (string)GetLocalSetting(MATConstants.SETTINGS_USERID_KEY);

            if (GetLocalSetting(MATConstants.SETTINGS_USERNAME_KEY) != null)
            {
                this.UserName = (string)GetLocalSetting(MATConstants.SETTINGS_USERNAME_KEY);
                this.UserNameMd5 = MATEncryption.Md5(this.UserName);
                this.UserNameSha1 = MATEncryption.Sha1(this.UserName);
                this.UserNameSha256 = MATEncryption.Sha256(this.UserName);
            }
        }