Exemplo n.º 1
0
 /// <summary>
 /// Initialize the specified appDelegate
 /// </summary>
 /// <returns>The initialize.</returns>
 /// <param name="appDelegate">App delegate.</param>
 /// <param name="licenseKey">License key.</param>
 public static void Initialize(UIKit.UIApplicationDelegate appDelegate, string licenseKey = null)
 {
     _initizalized = true;
     AppDelegate   = appDelegate;
     if (licenseKey != null)
     {
         System.Console.WriteLine("Forms9Patch is now open source using the MIT license ... so it's free, including for commercial use.  Why?  The more people who use it, the faster bugs will be found and fixed - which helps me and you.  So, please help get the word out - tell your friends, post on social media, write about it on the bathroom walls at work!  If you have purchased a license from me, please don't get mad - you did a good deed.  They really were not that expensive and you did a great service in encouraging me keep working on Forms9Patch.");
     }
     FormsGestures.iOS.Settings.Init();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Record the date this application was installed (or the date that we started recording installation date).
        /// </summary>
        public static DateTime StampInstallDate(this UIApplicationDelegate @this, string name, string key)
        {
            try
            {
                var query = new SecRecord(SecKind.GenericPassword)
                {
                    Service = name, Account = key
                };

                SecStatusCode secStatusCode;
                var           queriedRecord = SecKeyChain.QueryAsRecord(query, out secStatusCode);
                if (secStatusCode != SecStatusCode.Success)
                {
                    queriedRecord = new SecRecord(SecKind.GenericPassword)
                    {
                        Label       = name + " Install Date",
                        Service     = name,
                        Account     = key,
                        Description = string.Format("The first date {0} was installed", name),
                        Generic     = NSData.FromString(DateTime.UtcNow.ToString())
                    };

                    var err = SecKeyChain.Add(queriedRecord);
                    if (err != SecStatusCode.Success)
                    {
                        System.Diagnostics.Debug.WriteLine("Unable to save stamp date!");
                    }
                }
                else
                {
                    DateTime time;
                    if (!DateTime.TryParse(queriedRecord.Generic.ToString(), out time))
                    {
                        SecKeyChain.Remove(query);
                    }
                }

                return(DateTime.Parse(NSString.FromData(queriedRecord.Generic, NSStringEncoding.UTF8)));
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(DateTime.Now);
            }
        }